المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : New Thread and WM_QUIT



C++ Programming
04-08-2009, 09:13 PM
I don't like how, in a Windows environment, upon resetting the focus on a minimized window or having the window perform some other complex operation, the thread may stall (temporarily hang, not translating any messages). What if I want to break these operations?

Isn't it possible to spawn a new thread at initialization that either:
1)Solely searches the message queue for WM_QUIT and sets a global flag when triggered. Somehow, before performing any resource and time intensive operations (that might cause a small hang), any function calls check for the flag and break if it is present.

2)Or maybe have the entire message pump in the new thread, as a busy program isn't even able to receive messages while performing operations.

I think the biggest problems would be:
1)Having a separate thread pump messages from the parent
2)Figuring out how to break operations when the WM_QUIT flag (which was set in another thread) is set

Any input, tips, thoughts, examples that might help me?
Thanks, The Scientist.