System.TMonitor.Enter

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class procedure Enter(const AObject: TObject); overload; static; inline;
class function Enter(const AObject: TObject; Timeout: Cardinal): Boolean; overload; static;

C++

static void __fastcall Enter(TObject* const AObject)/* overload */;
static bool __fastcall Enter(TObject* const AObject, unsigned Timeout)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.pas
System.hpp
System TMonitor

Description

Prohibits the access of all other threads but the calling one to the specified object.

Use the Enter method to prohibit AObject from being accessed by threads other than the calling one.

Before attempting to lock the specified object, Enter tests whether the thread that is currently locking the object, if any, has made an equal number of calls to Enter and to Exit. If not, the calling thread is blocked from accessing the object until the previous thread releases it.

Note: A thread can make multiple calls to a TMonitor.Enter method without getting blocked as long as they invoke the same number of TMonitor.Exit methods to unblock the threads waiting on the object.

The Enter function attempts to lock the specified object for the amount of time designated by the Timeout parameter. If the lock attempt is successful, Enter returns True, otherwise it returns False.

See Also