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, TimeSpan timeout)

Parameters

obj
The object on which to wait. [Edit]
timeout
A TimeSpan set to the maximum amount of time 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]
ArgumentOutOfRangeExceptionIf timeout is negative, and is not equal to Timeout.Infinite , or is greater than int.MaxValue. [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 milliseconds is specified for timeout . Once the specified time has elapsed, this method returns a value that indicates whether the lock has been reacquired by the caller. If timeout 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