WPF DoEvents??

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.
 
J

Jon Skeet [C# MVP]

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.
 
C

cj

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top