Method LinkTimeCancellationToken
LinkTimeCancellationToken(Duration, CancellationToken)
Returns a disposable wrapper whose token is cancelled when either the specified duration elapses or the given cancellation token is cancelled. The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(Duration cancelAfter, CancellationToken cancellationToken)
Parameters
cancelAfterDurationThe duration to wait before cancelling the token.
cancellationTokenCancellationTokenThe cancellation token to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Remarks
Implementations may clamp values: zero or negative is treated as zero; durations greater than MaxValue milliseconds are clamped to that value, which is the maximum delay supported by CancellationTokenSource.
LinkTimeCancellationToken(Duration, CancellationToken, CancellationToken)
Returns a disposable wrapper whose token is cancelled when the specified duration elapses or any of the given tokens is cancelled. The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(Duration cancelAfter, CancellationToken firstCancellationToken, CancellationToken secondCancellationToken)
Parameters
cancelAfterDurationThe duration to wait before cancelling the token.
firstCancellationTokenCancellationTokenThe first cancellation token to link.
secondCancellationTokenCancellationTokenThe second cancellation token to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Remarks
Implementations may clamp values: zero or negative is treated as zero; durations greater than MaxValue milliseconds are clamped to that value, which is the maximum delay supported by CancellationTokenSource.
LinkTimeCancellationToken(Duration, params CancellationToken[])
Returns a disposable wrapper whose token is cancelled when the specified duration elapses or any of the given tokens is cancelled. The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(Duration cancelAfter, params CancellationToken[] cancellationTokens)
Parameters
cancelAfterDurationThe duration to wait before cancelling the token.
cancellationTokensCancellationToken[]The cancellation tokens to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Remarks
Implementations may clamp values: zero or negative is treated as zero; durations greater than MaxValue milliseconds are clamped to that value, which is the maximum delay supported by CancellationTokenSource.
LinkTimeCancellationToken(int, CancellationToken, CancellationToken)
Returns a disposable wrapper whose token is cancelled when the specified time elapses or any of the given tokens is cancelled. Disposing the returned instance disposes all underlying sources (including internal time-based sources). The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(int cancelMilliseconds, CancellationToken token1, CancellationToken token2)
Parameters
cancelMillisecondsintThe number of milliseconds to wait before cancelling the token.
token1CancellationTokenThe first cancellation token to link.
token2CancellationTokenThe second cancellation token to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Exceptions
- ArgumentOutOfRangeException
cancelMillisecondsis less than -1.
LinkTimeCancellationToken(TimeSpan, CancellationToken, CancellationToken)
Returns a disposable wrapper whose token is cancelled when the specified time elapses or any of the given tokens is cancelled. Disposing the returned instance disposes all underlying sources (including internal time-based sources). The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(TimeSpan cancelTime, CancellationToken token1, CancellationToken token2)
Parameters
cancelTimeTimeSpanThe time to wait before cancelling the token.
token1CancellationTokenThe first cancellation token to link.
token2CancellationTokenThe second cancellation token to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Exceptions
- ArgumentOutOfRangeException
cancelTimeis not a valid delay (for example, negative and not an infinite timeout, or too large to express in milliseconds).
LinkTimeCancellationToken(TimeSpan, CancellationToken)
Returns a disposable wrapper whose token is cancelled when either the specified time elapses or the given cancellation token is cancelled. Disposing the returned instance disposes all underlying sources (including internal time-based sources). The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(TimeSpan cancelTime, CancellationToken cancellationToken)
Parameters
cancelTimeTimeSpanThe time to wait before cancelling the token.
cancellationTokenCancellationTokenThe cancellation token to link; when it is cancelled, the returned wrapper's token is cancelled.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Exceptions
- ArgumentOutOfRangeException
cancelTimeis not a valid delay (for example, negative and not an infinite timeout, or too large to express in milliseconds).
LinkTimeCancellationToken(int, CancellationToken)
Returns a disposable wrapper whose token is cancelled when either the specified time elapses or the given cancellation token is cancelled. Disposing the returned instance disposes all underlying sources (including internal time-based sources). The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(int cancelMilliseconds, CancellationToken cancellationToken)
Parameters
cancelMillisecondsintThe number of milliseconds to wait before cancelling the token.
cancellationTokenCancellationTokenThe cancellation token to link; when it is cancelled, the returned wrapper's token is cancelled.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Exceptions
- ArgumentOutOfRangeException
cancelMillisecondsis less than -1.
LinkTimeCancellationToken(TimeSpan, params CancellationToken[])
Returns a disposable wrapper whose token is cancelled when the specified time elapses or any of the given tokens is cancelled. Disposing the returned instance disposes all underlying sources (including internal time-based sources). The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(TimeSpan cancelTime, params CancellationToken[] cancellationTokens)
Parameters
cancelTimeTimeSpanThe time to wait before cancelling the token.
cancellationTokensCancellationToken[]The cancellation tokens to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Exceptions
- ArgumentNullException
cancellationTokensis null.- ArgumentOutOfRangeException
cancelTimeis not a valid delay (for example, negative and not an infinite timeout, or too large to express in milliseconds).
LinkTimeCancellationToken(int, params CancellationToken[])
Returns a disposable wrapper whose token is cancelled when the specified time elapses or any of the given tokens is cancelled. Disposing the returned instance disposes all underlying sources (including internal time-based sources). The caller is responsible for disposing the returned instance when no longer needed.
public TimeCancellationTokenSource LinkTimeCancellationToken(int cancelMilliseconds, params CancellationToken[] cancellationTokens)
Parameters
cancelMillisecondsintThe number of milliseconds to wait before cancelling the token.
cancellationTokensCancellationToken[]The cancellation tokens to link.
Returns
- TimeCancellationTokenSource
A TimeCancellationTokenSource. Caller must dispose.
Exceptions
- ArgumentNullException
cancellationTokensis null.- ArgumentOutOfRangeException
cancelMillisecondsis less than -1.