Solved

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

Posted on 2013-06-06
7
1,391 Views
Last Modified: 2013-06-07
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
Comment
Question by:cycledude
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39228120
>>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
 

Author Comment

by:cycledude
ID: 39228137
Thanks andy

How do I go about setting the process to run in a separate thread?
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 39228148
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 13

Expert Comment

by:Naman Goel
ID: 39228151
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
 

Author Closing Comment

by:cycledude
ID: 39228154
thanks andy, thats great ;o)
0
 

Author Comment

by:cycledude
ID: 39228308
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
 
LVL 13

Expert Comment

by:Naman Goel
ID: 39228320
:) .
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

621 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