WPF DoEvents??

  • Thread starter Thread starter cj
  • Start date Start date
C

cj

Hi there, how might you implement a "wait" loop in WPF? (.net 3.0) without
freezing the UI?

previously I'd do something like this:

while (!someObject.IsProcessing){
Threading.Thread.Sleep(10);
Application.DoEvents();
}

....

but the DoEvents isn't there in wpf.

thanks,
chris.
 
cj said:
Hi there, how might you implement a "wait" loop in WPF? (.net 3.0) without
freezing the UI?

previously I'd do something like this:

while (!someObject.IsProcessing){
Threading.Thread.Sleep(10);
Application.DoEvents();
}

...

but the DoEvents isn't there in wpf.

It's a bad idea to do that even in Windows Forms, IMO. What purpose
does it actually serve that wouldn't be better achieved by using a
callback to the UI thread when the object has finished processing?

I don't see the point in adding an additional "waiting for
information" loop into a thread which already *has* a loop doing
exactly that - the message pump.
 
ya, I kinda figured I'd get that response! ;-)

of course, callbacks are better practice.

still though, sometimes it's handy to be able to do that

still wondering now you might do it.

thanks,
chris.
 
Back
Top