private Monitor_test_synchronised ( object obj ) : bool | ||
obj | object | |
Résultat | bool |
/// <summary>Notifies all waiting threads of a change in the object's state.</summary> /// <param name="obj">The object that sends the pulse. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="obj" /> parameter is null. </exception> /// <exception cref="T:System.Threading.SynchronizationLockException">The calling thread does not own the lock for the specified object. </exception> /// <filterpriority>1</filterpriority> public static void PulseAll(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } if (!Monitor.Monitor_test_synchronised(obj)) { throw new SynchronizationLockException("Object is not synchronized"); } Monitor.Monitor_pulse_all(obj); }
/// <summary>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.</summary> /// <returns>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.</returns> /// <param name="obj">The object on which to wait. </param> /// <param name="millisecondsTimeout">The number of milliseconds to wait before the thread enters the ready queue. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="obj" /> parameter is null. </exception> /// <exception cref="T:System.Threading.SynchronizationLockException">The calling thread does not own the lock for the specified object. </exception> /// <exception cref="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 <see cref="M:System.Threading.Thread.Interrupt" /> method. </exception> /// <exception cref="T:System.ArgumentOutOfRangeException">The value of the <paramref name="millisecondsTimeout" /> parameter is negative, and is not equal to <see cref="F:System.Threading.Timeout.Infinite" />. </exception> /// <filterpriority>1</filterpriority> public static bool Wait(object obj, int millisecondsTimeout) { if (obj == null) { throw new ArgumentNullException("obj"); } if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException("millisecondsTimeout", "timeout out of range"); } if (!Monitor.Monitor_test_synchronised(obj)) { throw new SynchronizationLockException("Object is not synchronized"); } return(Monitor.Monitor_wait(obj, millisecondsTimeout)); }