System.TMonitor.Enter
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. Other threads waiting will block until the running thread calls an equal number of TMonitor.Enter and TMonitor.Exit.
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.