Click to See Complete Forum and Search --> : How do I yield a thread in .NET?


phone_guy
January 14th, 2005, 12:04 PM
My application is importing data from a text file and is very processor intensive. I'd like to yield the process if there are any pending messages on my application's thread.

In MFC I was able to yield the app in this way:


MSG msg;

while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
AfxGetThread()->PumpMessage();



Anyone know how to do this in .NET?

phone_guy
January 14th, 2005, 01:03 PM
I hate when I answer my own post - but for anyone else who might have this question:

Use Application::doEvents() (with a capital d - stupid smiles...) from within your program to clean out messages in the message queue.