Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-13
4
Medium Priority
?
330 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 200 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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 …

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