Mono Class Library: System.Threading.Monitor Overview | Members

System.Threading.Monitor.TryEnter Method

Attempts to acquire an exclusive lock on the specified object.

public static bool TryEnter (object obj)

Parameters

obj
The object on which to acquire the lock.

Returns

true if the current thread acquired the lock; otherwise, false.

Exceptions

TypeReason
ArgumentNullExceptionobj is null.

Remarks

If successful, this method acquires an exclusive lock on obj. This method returns immediately, whether or not the lock is available.

This method is equivalent to Monitor.TryEnter(object) (obj, 0).

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0