Console Application.DoEvents() SOLVED!! example

yes i also got crazy about how to impersonate the glorious WinForms Application.DoEvents(), since if u do Thread.Sleep() the whole app stops!
it then came to mind its so simple:
//the condition is the events that u want to see done, u must oversee them, check
http://bresleveloper.blogspot.com/2012/05/muti-threading-in-forforeach-example.html
while (!AllThreadsFinished)
{
     //here is where DoEvents+Sleep u usualy go
     Thread waitThread = new Thread(() => WaitThread(100));
     waitThread.Start();                    
     waitThread.Join();
}
OH! extremely recommended to declare waitThread before the while and null it after else thing might get slow...
void WaitThread(int mls)
{            
     Thread.Sleep(mls);
}


P.S. - if u use classes with forms for some stuff like browser navigation u dont have a choise but using the winforms ref and use the DoEvents().

Comments

Popular posts from this blog

c# Service Play Sound with NAudio example by Moshe

JS/JQ simulate Enter event

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem