Thursday, May 17, 2012

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
while (!AllThreadsFinished)
     //here is where DoEvents+Sleep u usualy go
     Thread waitThread = new Thread(() => WaitThread(100));
OH! extremely recommended to declare waitThread before the while and null it after else thing might get slow...
void WaitThread(int 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().

No comments:

Post a Comment