Synchronization Using the DosWaitThread() Function (Part 2)

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  */

     <Store ThreadID in instance data block>

     WinStartTimer(hAB,                        /* Start timer            */
                   hwnd,                       /* Window to get WM_TIMER */
                   TID_THREAD,                 /* ID of timer            */
                   50);                        /* Period in milliseconds */
     break;
        :
case WM_TIMER:

     <Get ThreadID from instance data block>

     ulReturn=DosWaitThread(ThreadID,           /* Check thread status   */
                            DCWW_NOWAIT);       /* Immediate timeout     */
     if (ulReturn==ERROR_THREAD_NOT_TERMINATED) /* Thread still running  */
        break;                                  /* Continue waiting      */
     else                                       /* else                  */
        <perform end-of-thread processing>      /* Thread has completed  */
     break;

This example shows the window procedure in the primary thread, periodically testing to determine whether the secondary thread has terminated.


[Back: Synchronization Using the DosWaitThread() Function (Part 1)]
[Next: DosWaitChild() Function]