enterCriticalSection

Syntax

bool enterCriticalSection(int hCS)

Arguments

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

Return

This function returns true when access to this Critical Section is granted to the calling thread, or false if hCS is 0.

Description

This function waits for ownership of the specified Critical Section. If another thread currently owns this Critical Section, then this function waits until the owning thread leaves the Critical Section, at which point one of the threads waiting to enter the Critical Section is granted access. If no other thread currently owns the Critical Section, the calling thread is granted immediate access.

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, tryEnterCriticalSection, leaveCriticalSection, deleteCriticalSection

Comments

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