RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.MonitorEnter Function

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

Pascal
function MonitorEnter(AObject: TObject; Timeout: Cardinal = INFINITE): Boolean;
C++
Boolean MonitorEnter(TObject * AObject, unsigned Timeout = INFINITE);

Use the MonitorEnter function to prohibit AObject from being accessed by threads, other than the calling one.  

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

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

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!