case WMP_THREAD:
usReturn = DosCreateThread(ThreadID, /* Create thread */
Thread, /* Entry point for thread */
NULL, /* No initialization data */
0L, /* Start immediately */
4096); /* Stack size for thread */
WinStartTimer(hAB, /* Start timer */
hwnd, /* Window to get WM_TIMER */
TID_THREAD, /* ID of timer */
500); /* Period in milliseconds */
break;
:
case WM_TIMER:
ulResult=DosOpenEventSem("\SEM32\THREAD", /* Get semaphore handle */
hSem); /* Semaphore handle */
ulResult=DosWaitEventSem(hSem, /* Check semaphore state */
0); /* Immediate timeout */
if (ulResult!=ERROR_TIMEOUT) /* Semaphore not set */
{
<perform end-of-thread processing> /* Thread has completed */
}
ulResult=DosCloseEventSem(hSem); /* Close semaphore */
break;
This example shows the window procedure in the primary thread, periodically testing to determine whether the event semaphore has been released.