Lock Record

Definition

Provides an easy to use wrapper around TCriticalSection. It automatically initializes the TCriticalSection instance when required and destroys it when the Lock goes out of scope.

Delphi
type Lock = record

Methods

Enter

Calls Enter on the underlying TCriticalSection. The first call also initializes the TCriticalSection instance.

Leave

Calls Leave on the underlying TCriticalSection. If no call to Enter has been made before it will raise an exception.

ScopedLock

Calls Enter on the underlying TCriticalSection and returns an interface reference that will call Leave once it goes out of scope.