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

x
?
Solved

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

Posted on 2013-06-06
7
Medium Priority
?
1,406 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 2000 total points
ID: 39228148
0
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.

 
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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

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