Thread.Sleep(100);
Application.DoEvents();
and
Application.DoEvents();
Thread.Sleep(100);
I have seen applications with the first method and some with the second method. Heck, I wrote some applications that I got the desired results using the first method, and some to the second.
Any kind of explanation will be grealty appretiated.
The reason I am asking because I am writing an application (UI) where I need to wait a certain amount of time before the result is acheived. However, I have UI buttons that a user can click - and currently, when they click, the action doesn't take place until the GUI thread is done "sleeping". I tried:
for (..) // loop 8 times
{
Application.DoEvents();
But I didn't see that much improvement.
Can anyone suggest something to do in order to keep my application running smoothly and at the same time, allow it to wait for a certain number of msec