Do Other Processing (GUI Loop)
-
I know in Borland their is a command to check for other events when in a loop on a form. Are they something the same in Visual Studio. I am in a loop when I click a button, but need to check if another button/checkbox event needs to be processed; e.g. flag set to exit the loop. Or do I need to opt for a worker thread? Graham. grahamfff
-
I know in Borland their is a command to check for other events when in a loop on a form. Are they something the same in Visual Studio. I am in a loop when I click a button, but need to check if another button/checkbox event needs to be processed; e.g. flag set to exit the loop. Or do I need to opt for a worker thread? Graham. grahamfff
Putting your loop in a worker thread is usually the best way. Otherwise you have to check the message queue at regular intervals in your loop so that the GUI can handle the messages. If you are using MFC then a call to
AfxGetApp()->PumpMessage()
will do the trick. If not using MFC then you have to place calls toPeekMessage, TranslateMessage, and DispatchMessage
. See http://www.codeproject.com/threads/usingworkerthreads.asp[^].
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!