Solved

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

Posted on 2004-08-13
4
324 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now