Defference between 'WaitForSingleObject' and 'EnterCriticalSection' functions?

Please tell me the Defference between 'WaitForSingleObject' and 'EnterCriticalSection' functions.
If I want to protect a single variable across threads what should I use preferably?
TIA
Last edited on
WaitForSingleObject waits for a synchronisataion object to be signalled.

EnterCriticalSection waits for a CRITICAL_SECTION to become available.

A CRITICAL_SECTION is not a synchronisation object and doesn't have a handle and is incompatible with synchronisation object system calls. That's why it has it's own system calls. To use C++ speak, it's a different type of object.
Topic archived. No new replies allowed.