The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Task::Run<TResult> Method (Func<Task<TResult>^>^, CancellationToken)
.NET Framework (current version)
Queues the specified work to run on the thread pool and returns a proxy for the Task(TResult) returned by function.
Assembly: mscorlib (in mscorlib.dll)
public: generic<typename TResult> static Task<TResult>^ Run( Func<Task<TResult>^>^ function, CancellationToken cancellationToken )
Parameters
- function
-
Type:
System::Func<Task<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<TResult>^A Task(TResult) that represents a proxy for the Task(TResult) returned by function.
Type Parameters
- TResult
The type of the result returned by the proxy task.
| Exception | Condition |
|---|---|
| ArgumentNullException | The function parameter was null. |
| TaskCanceledException | The task has been canceled. |
| ObjectDisposedException | The CancellationTokenSource associated with cancellationToken was disposed. |
For information on handling exceptions thrown by task operations, see Exception Handling (Task Parallel Library).
Universal Windows Platform
Available since 8
.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
Available since 8
.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
Show: