mscorlib(4.0.0.0) API with additions
|
Provides a mechanism that synchronizes access to objects. More...
Public Member Functions | |
static void | Enter (object obj) |
Acquires an exclusive lock on the specified object. More... | |
static void | Exit (object obj) |
Releases an exclusive lock on the specified object. More... | |
Static Public Member Functions | |
static void | Enter (object obj, ref bool lockTaken) |
Acquires an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken. More... | |
static bool | TryEnter (object obj) |
Attempts to acquire an exclusive lock on the specified object. More... | |
static void | TryEnter (object obj, ref bool lockTaken) |
Attempts to acquire an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken. More... | |
static bool | TryEnter (object obj, int millisecondsTimeout) |
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified object. More... | |
static bool | TryEnter (object obj, TimeSpan timeout) |
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object. More... | |
static void | TryEnter (object obj, int millisecondsTimeout, ref bool lockTaken) |
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken. More... | |
static void | TryEnter (object obj, TimeSpan timeout, ref bool lockTaken) |
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken. More... | |
static bool | IsEntered (object obj) |
Determines whether the current thread holds the lock on the specified object. More... | |
static bool | Wait (object obj, int millisecondsTimeout, bool exitContext) |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. This method also specifies whether the synchronization domain for the context (if in a synchronized context) is exited before the wait and reacquired afterward. More... | |
static bool | Wait (object obj, TimeSpan timeout, bool exitContext) |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. Optionally exits the synchronization domain for the synchronized context before the wait and reacquires the domain afterward. More... | |
static bool | Wait (object obj, int millisecondsTimeout) |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. More... | |
static bool | Wait (object obj, TimeSpan timeout) |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. More... | |
static bool | Wait (object obj) |
Releases the lock on an object and blocks the current thread until it reacquires the lock. More... | |
static void | Pulse (object obj) |
Notifies a thread in the waiting queue of a change in the locked object's state. More... | |
static void | PulseAll (object obj) |
Notifies all waiting threads of a change in the object's state. More... | |
Provides a mechanism that synchronizes access to objects.
Definition at line 13 of file Monitor.cs.
static void System.Threading.Monitor.Enter | ( | object | obj | ) |
Acquires an exclusive lock on the specified object.
obj | The object on which to acquire the monitor lock. |
T:System.ArgumentNullException | The obj parameter is null . |
|
static |
Acquires an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken.
obj | The object on which to wait. |
lockTaken | 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 . |
T:System.ArgumentException | The input to lockTaken is true . |
T:System.ArgumentNullException | The obj parameter is null . |
Definition at line 29 of file Monitor.cs.
static void System.Threading.Monitor.Exit | ( | object | obj | ) |
Releases an exclusive lock on the specified object.
obj | The object on which to release the lock. |
T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | The current thread does not own the lock for the specified object. |
|
static |
Determines whether the current thread holds the lock on the specified object.
obj | The object to test. |
true
if the current thread holds the lock on obj ; otherwise, false
.T:System.ArgumentNullException | obj is null . |
Definition at line 171 of file Monitor.cs.
|
static |
Notifies a thread in the waiting queue of a change in the locked object's state.
obj | The object a thread is waiting for. |
T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | The calling thread does not own the lock for the specified object. |
Definition at line 280 of file Monitor.cs.
|
static |
Notifies all waiting threads of a change in the object's state.
obj | The object that sends the pulse. |
T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | The calling thread does not own the lock for the specified object. |
Definition at line 299 of file Monitor.cs.
|
static |
Attempts to acquire an exclusive lock on the specified object.
obj | The object on which to acquire the lock. |
true
if the current thread acquires the lock; otherwise, false
.T:System.ArgumentNullException | The obj parameter is null . |
Definition at line 63 of file Monitor.cs.
|
static |
Attempts to acquire an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken.
obj | The object on which to acquire the lock. |
lockTaken | 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. |
T:System.ArgumentException | The input to lockTaken is true . |
T:System.ArgumentNullException | The obj parameter is null . |
Definition at line 76 of file Monitor.cs.
|
static |
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified object.
obj | The object on which to acquire the lock. |
millisecondsTimeout | The number of milliseconds to wait for the lock. |
true
if the current thread acquires the lock; otherwise, false
.T:System.ArgumentNullException | The obj parameter is null . |
T:System.ArgumentOutOfRangeException | millisecondsTimeout is negative, and not equal to F:System.Threading.Timeout.Infinite. |
Definition at line 94 of file Monitor.cs.
|
static |
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.
obj | The object on which to acquire the lock. |
timeout | A T:System.TimeSpan representing the amount of time to wait for the lock. A value of –1 millisecond specifies an infinite wait. |
true
if the current thread acquires the lock; otherwise, false
.T:System.ArgumentNullException | The obj parameter is null . |
T:System.ArgumentOutOfRangeException | The value of timeout in milliseconds is negative and is not equal to F:System.Threading.Timeout.Infinite (–1 millisecond), or is greater than F:System.Int32.MaxValue. |
Definition at line 119 of file Monitor.cs.
|
static |
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken.
obj | The object on which to acquire the lock. |
millisecondsTimeout | The number of milliseconds to wait for the lock. |
lockTaken | 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. |
T:System.ArgumentException | The input to lockTaken is true . |
T:System.ArgumentNullException | The obj parameter is null . |
T:System.ArgumentOutOfRangeException | millisecondsTimeout is negative, and not equal to F:System.Threading.Timeout.Infinite. |
Definition at line 133 of file Monitor.cs.
|
static |
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object, and atomically sets a value that indicates whether the lock was taken.
obj | The object on which to acquire the lock. |
timeout | The amount of time to wait for the lock. A value of –1 millisecond specifies an infinite wait. |
lockTaken | 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. |
T:System.ArgumentException | The input to lockTaken is true . |
T:System.ArgumentNullException | The obj parameter is null . |
T:System.ArgumentOutOfRangeException | The value of timeout in milliseconds is negative and is not equal to F:System.Threading.Timeout.Infinite (–1 millisecond), or is greater than F:System.Int32.MaxValue. |
Definition at line 150 of file Monitor.cs.
|
static |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. This method also specifies whether the synchronization domain for the context (if in a synchronized context) is exited before the wait and reacquired afterward.
obj | The object on which to wait. |
millisecondsTimeout | The number of milliseconds to wait before the thread enters the ready queue. |
exitContext | true to exit and reacquire the synchronization domain for the context (if in a synchronized context) before the wait; otherwise, false . |
true
if the lock was reacquired before the specified time elapsed; false
if the lock was reacquired after the specified time elapsed. The method does not return until the lock is reacquired.T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | Wait is not invoked from within a synchronized block of code. |
T:System.Threading.ThreadInterruptedException | The thread that invokes Wait is later interrupted from the waiting state. This happens when another thread calls this thread's M:System.Threading.Thread.Interrupt method. |
T:System.ArgumentOutOfRangeException | The value of the millisecondsTimeout parameter is negative, and is not equal to F:System.Threading.Timeout.Infinite. |
Definition at line 201 of file Monitor.cs.
|
static |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. Optionally exits the synchronization domain for the synchronized context before the wait and reacquires the domain afterward.
obj | The object on which to wait. |
timeout | A T:System.TimeSpan representing the amount of time to wait before the thread enters the ready queue. |
exitContext | true to exit and reacquire the synchronization domain for the context (if in a synchronized context) before the wait; otherwise, false . |
true
if the lock was reacquired before the specified time elapsed; false
if the lock was reacquired after the specified time elapsed. The method does not return until the lock is reacquired.T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | Wait is not invoked from within a synchronized block of code. |
T:System.Threading.ThreadInterruptedException | The thread that invokes Wait is later interrupted from the waiting state. This happens when another thread calls this thread's M:System.Threading.Thread.Interrupt method. |
T:System.ArgumentOutOfRangeException | The timeout parameter is negative and does not represent F:System.Threading.Timeout.Infinite (–1 millisecond), or is greater than F:System.Int32.MaxValue. |
Definition at line 222 of file Monitor.cs.
|
static |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue.
obj | The object on which to wait. |
millisecondsTimeout | The number of milliseconds to wait before the thread enters the ready queue. |
true
if the lock was reacquired before the specified time elapsed; false
if the lock was reacquired after the specified time elapsed. The method does not return until the lock is reacquired.T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | The calling thread does not own the lock for the specified object. |
T:System.Threading.ThreadInterruptedException | The thread that invokes Wait is later interrupted from the waiting state. This happens when another thread calls this thread's M:System.Threading.Thread.Interrupt method. |
T:System.ArgumentOutOfRangeException | The value of the millisecondsTimeout parameter is negative, and is not equal to F:System.Threading.Timeout.Infinite. |
Definition at line 237 of file Monitor.cs.
|
static |
Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue.
obj | The object on which to wait. |
timeout | A T:System.TimeSpan representing the amount of time to wait before the thread enters the ready queue. |
true
if the lock was reacquired before the specified time elapsed; false
if the lock was reacquired after the specified time elapsed. The method does not return until the lock is reacquired.T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | The calling thread does not own the lock for the specified object. |
T:System.Threading.ThreadInterruptedException | The thread that invokes Wait is later interrupted from the waiting state. This happens when another thread calls this thread's M:System.Threading.Thread.Interrupt method. |
T:System.ArgumentOutOfRangeException | The value of the timeout parameter in milliseconds is negative and does not represent F:System.Threading.Timeout.Infinite (–1 millisecond), or is greater than F:System.Int32.MaxValue. |
Definition at line 252 of file Monitor.cs.
|
static |
Releases the lock on an object and blocks the current thread until it reacquires the lock.
obj | The object on which to wait. |
true
if the call returned because the caller reacquired the lock for the specified object. This method does not return if the lock is not reacquired.T:System.ArgumentNullException | The obj parameter is null . |
T:System.Threading.SynchronizationLockException | The calling thread does not own the lock for the specified object. |
T:System.Threading.ThreadInterruptedException | The thread that invokes Wait is later interrupted from the waiting state. This happens when another thread calls this thread's M:System.Threading.Thread.Interrupt method. |
Definition at line 265 of file Monitor.cs.