Class TimeCancellationTokenSource
Wraps one or more CancellationTokenSource instances used for time-based cancellation, exposing token and cancel operations and ensuring all underlying sources are disposed when this instance is disposed.
public sealed class TimeCancellationTokenSource : IDisposable
- Inheritance
-
TimeCancellationTokenSource
- Implements
Remarks
Callers dispose this wrapper instead of a raw CancellationTokenSource. Disposing this instance disposes the primary source and any related intermediate sources (e.g. the internal time-based source used when linking tokens), avoiding resource leaks that occur when only a linked BCL source is disposed.
Properties
- IsCancellationRequested
Gets whether cancellation has been requested for this token.
- Token
Gets the cancellation token associated with the primary source.
Methods
- Cancel()
Communicates a request for cancellation.
- Cancel(bool)
Communicates a request for cancellation and specifies whether an exception should be thrown if cancellation is successful.
- Dispose()
Disposes the primary CancellationTokenSource and any additional sources supplied at construction.