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

System.Threading.Monitor.Wait Method

Releases the lock on an object and blocks the current thread until it reacquires the lock or until a specified amount of time elapses. [Edit]

public static bool Wait (object obj, int millisecondsTimeout)

Parameters

obj
The object on which to wait. [Edit]
millisecondsTimeout
A int containing the maximum number of milliseconds to wait before this method returns. [Edit]

Returns

true if the lock was reacquired before the specified time elapsed; otherwise, false. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionobj is null. [Edit]
System.Threading.SynchronizationLockExceptionThe calling thread does not own the lock for the specified object. [Edit]
ArgumentOutOfRangeExceptionThe value of millisecondsTimeout is negative, and not equal to Timeout.Infinite . [Edit]

Remarks

If successful, this method reacquires an exclusive lock on obj.

This method behaves identically to Monitor.Wait(object, int, bool) (obj), except that it does not block indefinitely unless Timeout.Infinite is specified for millisecondsTimeout . Once the specified time has elapsed, this method returns a value that indicates whether the lock has been reacquired by the caller. If millisecondsTimeout equals 0, this method returns immediately.

Note: This method is called when the caller is waiting for a change in the state of the object, which occurs as a result of another thread's operations on the object. For additional details, see Monitor.Wait(object, int, bool) (obj).

[Edit]

Requirements

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