WinWaitEventSem is similar to DosWaitEventSem and enables a thread to wait for an event semaphore to be posted or for a window message sent by WinSendMsg from another thread to be received.

This function can be called by any thread in the process that created the semaphore. Threads in other processes can also call this function, but they must first gain access to the semaphore by calling DosOpenEventSem.

Since the processing of a window message may take longer than the value specified by the ulTimeout parameter, this function may not return within the time specified by that value.

If the main thread (which normally processes messages) is waiting on a semaphore for a prolonged period of time, messages will not be processed, and the "Bad App" dialog can occur. This is expected behavior. To avoid this, a message-box can be displayed telling the user that the window is being initialized. While the window loads, that message box can process the incoming system messages.


[Back] [Next]