Wait Method (Int32, CancellationToken)

Task Parallel System.Threading

Blocks the current thread until the current ManualResetEventSlim is set, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.

Namespace:  System.Threading
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
	millisecondsTimeout As Integer, _
	cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
	int millisecondsTimeout,
	CancellationToken cancellationToken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the ManualResetEventSlim was set; otherwise, false.

Exceptions

ExceptionCondition
System..::.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException The maximum number of waiters has been exceeded.
OperationCanceledExceptioncancellationToken was canceled.

See Also