From RAD Studio API Documentation
Jump to: navigation, search


function SleepCS(var CriticalSection: TRTLCriticalSection; dwMilliseconds: DWORD): Boolean;


Type Visibility Source Unit Parent
function public System.SyncObjs.pas System.SyncObjs TConditionVariableHelper


Sleeps on the condition variable and releases the given critical section.

Call SleepCS to sleep on the condition variable and to release the critical section specified through the CriticalSection parameter.

The dwMilliseconds parameter sets the time-out interval. When this interval elapses, the critical section is reacquired, even if the condition variable has not been awakened by other threads.

Condition variables might suddenly wake up without making an explicit call to the Wake or to the WakeAll method. Also, other threads might run before the thread that sleeps on the condition variable is awakened. Therefore, make the call to SleepCS inside a loop. To avoid the above mentioned errors, the loop should test that the desired condition becomes true even after the condition variable has awakened.

See Also