The information in this article applies to:
MORE INFORMATION
To receive notification when a process has terminated, a Win32 application
may call WaitForSingleObject() and specify the process handle of the
application to be waited on. Normally, this will cause the waiting process
to block until the application being waited on terminates. Then
WaitForSingleObject() will return WAIT_OBJECT_0 and the waiting process
will continue to execute.
Q136885 INFO: OLE Threads Must Dispatch MessagesTo prevent this deadlock, the waiting application should wait in a separate thread, thus freeing the main thread to process messages. When the process that is being waited on completes and WaitForSingleObject() returns, the waiting thread can notify the main thread by sending a user-defined message to the message queue of the main window. The main thread will interpret the user-defined message as completion of the waited-on process. For more information about user-defined messages, please refer to the following Knowledge Base article: Q86835 HOWTO: Define Private Messages for Application UseAnother way to avoid this problem is to have the waiting thread call MsgWaitForMultipleObjects() in a loop, which calls DispachMessage() when a message needs to be processed. For an example of this technique see the Knowledge Base article referenced above on the OLE problem (Q136885). SYMPTOMSA deadlock results when a process waits on the handle of another process that broadcasts a message. CAUSEThis occurs when the waiting process is waiting in the thread that processes the messages sent to the window (the main window thread). RESOLUTIONTo prevent this deadlock situation the waiting process can wait in a separate thread, leaving the main window thread free to process window messages, or use the MsgWaitForMultipleObjects() API in conjunction with the dispatching messages. Additional query words: Setup
Keywords : |
Last Reviewed: January 14, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |