By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

WPF DoEvents??

P: n/a
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.

Apr 23 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
cj <so*****@mydomain.comwrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 23 '07 #2

P: n/a
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.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
cj <so*****@mydomain.comwrote:
>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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.