DeleteCriticalSection function (synchapi.h)

Releases all resources used by an unowned critical section object.

Syntax

void DeleteCriticalSection(
  [in, out] LPCRITICAL_SECTION lpCriticalSection
);

Parameters

[in, out] lpCriticalSection

A pointer to the critical section object. The object must have been previously initialized with the InitializeCriticalSection function.

Return value

None

Remarks

Deleting a critical section object releases all system resources used by the object. The caller is responsible for ensuring that the critical section object is unowned and the specified CRITICAL_SECTION structure is not being accessed by any critical section functions called by other threads in the process.

After a critical section object has been deleted, do not reference the object in any function that operates on critical sections (such as EnterCriticalSection, TryEnterCriticalSection, and LeaveCriticalSection) other than InitializeCriticalSection and InitializeCriticalSectionAndSpinCount. If you attempt to do so, memory corruption and other unexpected errors can occur.

If a critical section is deleted while it is still owned, the state of the threads waiting for ownership of the deleted critical section is undefined.

Examples

For an example that uses DeleteCriticalSection, see Using Critical Section Objects.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header synchapi.h (include Windows.h on Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 Windows Server 2008 R2)
Library Kernel32.lib
DLL Kernel32.dll

See also

Critical Section Objects

EnterCriticalSection

InitializeCriticalSection

LeaveCriticalSection

Synchronization Functions

TryEnterCriticalSection

Vertdll APIs available in VBS enclaves