leaveCriticalSection

Syntax

bool leaveCriticalSection(int hCS)

Arguments

hCS
Specifies the handle of the Critical Section to be exited, as returned by a call to createCriticalSection.

Return

This function returns true after immediately relinquishing ownership of the Critical Section. It returns false if hCS is zero.

Description

This function exits a specified Critical Section, thereby relinquishing ownership of it and allowing another waiting thread to enter the Critical Section. Critical Sections must be exited in the reverse order in which they were entered. It is an error to exit a Critical Section that is not owned by the current thread. A thread may enter a specific Critical Section several times (i.e., in a nested or recursive fashion), in which case it must also exit the Critical Section the same number of times before another thread can gain access to it.

For more information about Critical Sections, see the MSDN documentation about [Critical Section Objects].

Example

See the createCriticalSection example.

Also see

System Functions, Critical Section Functions, createCriticalSection, enterCriticalSection, tryEnterCriticalSection, deleteCriticalSection

Comments

Everyone can add her or his comments about her or his experiences with this function. Tips for using it are welcome, too.