Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0



Morten,

Application.DoEvents() did everything I need.
You are right I don't need the Refresh();

However, I wish I understand what does that mean. I need help
understanding what does Application.DoEvents() mean and why it solved my
Problem.

I will also look into the BackgroundWorker solution, As soon as I have time
and the "big cheese" goes invisible, I think that would be best on the long
run?

Thank you so much for your help.

OZI



"Morten Wennevik [C# MVP]" <MortenWennevik@xxxxxxxxxxx> wrote in message
news:op.tylx3thedj93y5@xxxxxxxx
On Thu, 13 Sep 2007 21:06:55 +0200, OZI <sql_agentman@xxxxxxxxxxx> wrote:


for (int x = 0; x < progressBar1.Maximum ; x++)

{

progressBar1.Increment(1);

System.Threading.Thread.Sleep(1000);

this.Refresh();

}


Telling the window to refresh itself isn't helping much since you don't give
it any time to handle user interaction. If you add Application.DoEvents()
after Refresh() (or instead of as you don't need to refresh to update the
progress bar) you should see a noticeable difference. Alternately go the
BackgroundWorker way (see the code sample in my other reply).



--
Happy coding!
Morten Wennevik [C# MVP]


.



Relevant Pages


Loading