Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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