Waits for and removes units from an RT semaphore. Execution continues when the units are available, or the thread has been waiting for the specified maximum amount of time.
WORD ntxWaitForRtSemaphore(
    NTXHANDLE hSemaphore,
    WORD wUnits,
    DWORD dwMilliseconds
);
hSemaphore 
wUnits 
dwMilliseconds 
| NO_WAIT | The thread does not wait. | 
| INFINITE | The thread waits for its request to be fully satisfied. | 
| Any positive integer | Calling thread goes to sleep for this many milliseconds, after which it awakes. | 
E_OK 0x0000 
E_TIME 0x0001 
One of these is true:
dwMilliseconds expired while waiting in the thread queue before the requested units were available. E_LIMIT 0x0004 
wUnits is greater than the maximum number of units the semaphore can contain. 
E_EXIST 0x0006 
hSemaphore is not a handle for an existing object. 
E_TYPE 0x8002 
hSemaphore is not a handle for a semaphore. 
E_NTX_INTERNAL_ERROR 
| Versions | Defined in | Include | Link to | 
|---|---|---|---|
| INtime 3.0 | intime/nt/include/ntx.h | ntx.h | ntx.lib | 
| INtime 4.01 (for 64-bit Windows) | intime/nt/include/ntx.h | ntx.h | ntx64.lib | 
Warning: There is the possibility of confusion regarding the return value in the case where a semaphore:
a) has the maximum of 65535 units, and
b) ntxWaitForRtSemaphore is called with a request for zero units.
In this case the return value is 65535, which is also the value of the error value NTX_ERROR.