An application can create a deadlock condition in Windows if it yields control while processing a message sent from another application (or by Windows on behalf of another application) by using the SendMessage function.
Typically, a task that calls SendMessage to send a message to another task
does not continue running until the window procedure that receives the message
returns. When the task that receives the message yields control, the sending task
cannot continue to run and to process messages because it is waiting for SendMessage to return, resulting in a message deadlock.
The application processing the message does not have to yield explicitly to cause the problem. Calling any one of the following functions can result in the application yielding control:
Before calling any of these functions while processing a message, a window procedure should first call the InSendMessage function to find out whether the message was sent by the SendMessage function from another application. If InSendMessage returns a nonzero value, the window procedure must call the ReplyMessage function before calling any function that yields control.