CRITICAL_SECTION CritSection; CONDITION_VARIABLE ConditionVar; void PerformOperationOnSharedData() { EnterCriticalSection(&CritSection); // Wait until the predicate is TRUE while( TestPredicate() == FALSE ) { SleepConditionVariableCS(&ConditionVar, &CritSection, INFINITE); } // The data can be changed safely because we own the critical // section and the predicate is TRUE ChangeSharedData(); LeaveCriticalSection(&CritSection); // If necessary, signal the condition variable by calling // WakeConditionVariable or WakeAllConditionVariable so other // threads can wake }