This example causes the calling thread to wait until the specified event semaphore is posted. Assume that the handle of the semaphore has been placed into hev already.

ulTimeout is the number of milliseconds that the calling thread will wait for the event semaphore to be posted. If the specified event semaphore is not posted during this time interval, the request times out.

#define INCL_DOSSEMAPHORES   /* Semaphore values               */
#define INCL_WINMESSAGEMGR
#include <os2.h>
#include <stdio.h>

#ifndef ERROR_TIMEOUT
  #define  ERROR_TIMEOUT    640
  #define  ERROR_INTERRUPT  95
#endif

HEV   hev;                   /* Event semaphore handle         */
ULONG ulTimeout;             /* Number of milliseconds to wait */
ULONG rc;                    /* Return code                    */

ulTimeout = 60000;           /* Wait for a maximum of 1 minute */

rc = WinWaitEventSem(hev, ulTimeout);

if (rc == ERROR_TIMEOUT)
   {
     printf("WinWaitEventSem call timed out");
     return;
   }

if (rc == ERROR_INTERRUPT)
   {
     printf("WinWaitEventSem call was interrupted");
     return;
   }

if (rc != 0)
   {
     printf("WinWaitEventSem error: return code = %ld", rc);
     return;
   }


[Back] [Next]