ThreadingTools::WithCancellation<T> Method (Task<T>^, CancellationToken)
Visual Studio 2015
Wraps a task with one that will complete as cancelled based on a cancellation token, allowing someone to await a task but be able to break out early by cancelling the token.
Assembly: Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)
public: generic<typename T> [ExtensionAttribute] static Task<T>^ WithCancellation( Task<T>^ task, CancellationToken cancellationToken )
Parameters
- task
-
Type:
System.Threading.Tasks::Task<T>^
The task to wrap.
- cancellationToken
-
Type:
System.Threading::CancellationToken
The token that can be canceled to break out of the await.
Type Parameters
- T
The type of value returned by the task.
Show: