Click or drag to resize
MonitorEnter Method (Object, Boolean)
Acquires an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken.

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static void Enter(
	Object obj,
	ref bool lockTaken
)

Parameters

obj
Type: SystemObject
The object on which to wait.
lockTaken
Type: SystemBoolean
The result of the attempt to acquire the lock, passed by reference. The input must be false. The output is true if the lock is acquired; otherwise, the output is false. The output is set even if an exception occurs during the attempt to acquire the lock. Note   If no exception occurs, the output of this method is always true.
Exceptions
ExceptionCondition
ArgumentExceptionThe input to lockTaken is true.
ArgumentNullExceptionThe obj parameter is null.
See Also