Task.Run Method (Func(Of Task), CancellationToken)

.NET Framework 4.6 and 4.5

Queues the specified work to run on the thread pool and returns a proxy for the task returned by function.

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

Public Shared Function Run (
	function As Func(Of Task),
	cancellationToken As CancellationToken
) As Task


Type: System.Func(Of Task)

The work to execute asynchronously.

Type: System.Threading.CancellationToken

A cancellation token that should be used to cancel the work.

Return Value

Type: System.Threading.Tasks.Task

A task that represents a proxy for the task returned by function.

Exception Condition

The function parameter was null.


The task has been canceled.


The CancellationTokenSource associated with cancellationToken was disposed.


The Run(Func(Of Task), CancellationToken) method is used by language compilers to support the async and await keywords. It is not intended to be called directly from user code.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft