Using a Non-Blocking Versions of Win32 Wait Functions

Environment: VC6, NT4/2000/XP

Current implementations of the Win32 wait functions—such as Sleep(), WaitForSingleObject(), and WaitForMultipleObjects()—will block the message pump when called on a window thread. A special case of this is a thread that calls CoInitialize(), resulting in potentially blocking COM method calls to an object. The attached code is a MS VC++ static library project that caters to this problem by using MsgWaitForMultipleObjects to rewrite the functions such that if there are pending messages in the message queue, they are processed during the wait.

Downloads

Download source – 3.28 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read