December 09, 2007

How to use critical section?

// Declaration
CRITICAL_SECTION CriticalSection;

// Initialize
::InitializeCriticalSection(&CriticalSection);

// Implementation
::EnterCriticalSection(&CriticalSection);
/* Code block */
::LeaveCriticalSection(&CriticalSection);

// Uninitialize
::DeleteCriticalSection(&CriticalSection);