System.Threading.ManualResetEventSlim.Wait C# (CSharp) Method

Wait() public method

public Wait ( TimeSpan timeout ) : bool
timeout TimeSpan
return bool
        public bool Wait(TimeSpan timeout)
        {
            return Wait (CheckTimeout (timeout), CancellationToken.None);
        }

Same methods

ManualResetEventSlim::Wait ( TimeSpan timeout, CancellationToken cancellationToken ) : bool
ManualResetEventSlim::Wait ( int millisecondsTimeout ) : bool
ManualResetEventSlim::Wait ( int millisecondsTimeout, CancellationToken cancellationToken ) : bool
ManualResetEventSlim::Wait ( ) : void
ManualResetEventSlim::Wait ( CancellationToken cancellationToken ) : void

Usage Example

示例#1
0
		public void BasicUsageTest ()
		{
			int[] array = null;
			var evt = new ManualResetEventSlim (false);

			var buffer = new BatchBlock<int> (10);
			var block = new ActionBlock<int[]> (i =>
			{
				array = i;
				evt.Set ();
			});
			buffer.LinkTo<int[]> (block);

			for (int i = 0; i < 9; i++)
				Assert.IsTrue (buffer.Post (i));

			Assert.IsFalse (evt.Wait (100));

			Assert.IsNull (array);

			Assert.IsTrue (buffer.Post (42));
			Assert.IsTrue (evt.Wait (1000));

			Assert.IsNotNull (array);
			CollectionAssert.AreEqual (new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 42 }, array);
		}
All Usage Examples Of System.Threading.ManualResetEventSlim::Wait