Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1432
  • Last Modified:

c# 2010 winforms update animated gif without using application.doevents

HI

I have an application which has a few processes which can take some time to complete, especially over the network.  So to give the user some feedback, I have a hidden panel, which I make visible once the process starts, and remove it from the screen when the process finished... in the panel I have a animated gif (ajax load type) and a message saying the system is thinking...

trouble it, the animated gif doesn't update without doing an application.doevents (putting this in makes the process take twice as long)

so is there any way for me to refresh the animated gif so that the animation will play fluid?


Cheers

CD
0
cycledude
Asked:
cycledude
  • 3
  • 2
  • 2
1 Solution
 
AndyAinscowCommented:
>>so is there any way for me to refresh the animated gif so that the animation will play fluid?


Yes, but you might not like it.
The DoEvents is to force the main thread to process any waiting messages.  Actions that take a long time to complete (such as yours) really should be done in a separate thread to allow the main thread to work normally.  So, to make your app work 'correctly' you should do the process in another thread.  (It shouldn't be too much more recoding but definately more than just adding a DoEvents in a loop somewhere).
0
 
cycledudeAuthor Commented:
Thanks andy

How do I go about setting the process to run in a separate thread?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Naman GoelSoftware engineer 1Commented:
There are so many ways to achieve this, the easiest and robust one is by using backgroundworker, move your time consuming code in dowork event handler.

The other was to use Delegate

create a method for your time consuming method and call it in using BeginInvoke method.
0
 
cycledudeAuthor Commented:
thanks andy, thats great ;o)
0
 
cycledudeAuthor Commented:
sorry naman_goel, I didn't see your response before I awarded the points, otherwise you would have had a share, because your suggestion looks like it work too..
0
 
Naman GoelSoftware engineer 1Commented:
:) .
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now