Solved

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

Posted on 2004-08-13
4
329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

632 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