System.Threading.Monitor.Monitor_wait C# (CSharp) Method

Monitor_wait() private method

private Monitor_wait ( object obj, int ms ) : bool
obj object
ms int
return bool
		private extern static bool Monitor_wait(object obj, int ms);

Usage Example

示例#1
0
 /// <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));
 }
All Usage Examples Of System.Threading.Monitor::Monitor_wait