Task.Run(Of TResult) Method (Func(Of Task(Of TResult)), CancellationToken)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Queues the specified work to run on the ThreadPool and returns a proxy for the Task(TResult) returned by function.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Shared Function Run(Of TResult) ( _ function As Func(Of Task(Of TResult)), _ cancellationToken As CancellationToken _ ) As Task(Of TResult)
Type Parameters
- TResult
The type of the result returned by the proxy Task.
Parameters
- function
- Type: System.Func(Of Task(Of TResult))
The work to execute asynchronously
- cancellationToken
- Type: System.Threading.CancellationToken
A cancellation token that should be used to cancel the work
Return Value
Type: System.Threading.Tasks.Task(Of TResult)A Task(TResult) that represents a proxy for the Task(TResult) returned by function.
| Exception | Condition |
|---|---|
| ArgumentNullException | The function parameter was null. |
| ObjectDisposedException | The CancellationTokenSource associated with cancellationToken was disposed. |
Show: