Solved

Problem with .GIF on Windows Form.....

Posted on 2004-08-13
4
326 Views
Last Modified: 2012-06-27
Hello Experts,
     I am trying to show a .GIF (animated one) file onto the Windows Form. I am just attaching a GIF file to a PictureBox.
But By Default visibility of the PictureBox is false and on a perticular event I am making it's visibility true.
But the problem is it is not becoming visible until next statements gets executed.

e.g.
pictureBox1.Visible = true;
for(int i=0;i<1000000000;i++)
{
     i=i;
}
MessageBox.Show("I am coming first...");  

in this case GIF will be visible after showing the message box.


Is there any work aroung for this....?????????

Thanks
Bharat

0
Comment
Question by:bharat_mane
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
TheAvenger earned 50 total points
ID: 11790852
As you have a high load after the Visible = true statement, the paint event, which has a very low priority, is not called until the loop is over. So just call Application.DoEvents() after the Visible = true; statement and this should fix the problem
0
 

Author Comment

by:bharat_mane
ID: 11791493
Hi TheAvenger,
    Thanks a lot ...
       Now it's working fine.
    But I have one more doubt, If you want then i will put it in different question also.
Actually this gif is serving purpose of Progress bar. Because I have some operations like Upload and Download
and for this I wanted to show the status of Upload/Download.
But I didn't got any soln for this so I am just showing this GIF when upload starts and and making it invisible when it stops

   Actually this Upload/Download is not exactly file Upload and Download but the data which Excel files contains is going to SQL databse and vice-versa.

Is there any way to show progress bar for this kind of operation.


Thanks once again
Bharat
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 11791799
In general the best solution to such a problem is to create two threads. The first thread (this is the main thread of the application which already exists) handles all UI objects, so the form, the buttons, the progress bar, etc. The second thread would execute the real work, in your case make the upload. The problems are how to synchronize the two threads, e.g. how the working thread can tell the UI thread to move the progress bar one step further. There are solutions about this but you have to be careful the first time and read a little about it. Try searching the MSDN (http://msdn.microsoft.com/library) for multithreading tutorials as I don't have any link at the moment
0
 

Author Comment

by:bharat_mane
ID: 11791849
Thank you very much
I will check it and try to implement it.

Thanks
Bharat
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
About delegates in c sharp 3 49
System.Security 2 27
Device Location 4 29
EF5: Question about Metadata Artifact Processing 4 15
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question