Holding a critical section during SendMessage

Can you spot the defect with the following code? EnterCriticalSection(&cs);SendMessage(hwnd, WM_MYMESSAGE, 0, 0);LeaveCriticalSection(&cs); The problem is that the SendMessage() is a blocking call, and Windows can do many things from within this call.  This creates a situation that is highly prone to deadlocking. In the best case scenario, the application will remain responsive but its…