Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Threading.​Tasks.​Task<​TResult>

Assembly: System.Runtime

Inheritance: object → Task → Task

Implemented Interfaces

Represents an asynchronous operation that can return a value.

Properties

public static TaskFactory<​TResult>
Factory
Gets a factory method for creating and configuring <see cref="T:System.Threading.Tasks.Task`1" /> instances.
public TResult
Result
Gets the result value of this <see cref="T:System.Threading.Tasks.Task`1" /> .
public object
AsyncState
Gets the state object supplied when the <see cref="T:System.Threading.Tasks.Task" /> was created, or null if none was supplied.
CreationOptions
Gets the <see cref="T:System.Threading.Tasks.TaskCreationOptions" /> used to create this task.
Exception
Gets the <see cref="T:System.AggregateException" /> that caused the <see cref="T:System.Threading.Tasks.Task" /> to end prematurely. If the <see cref="T:System.Threading.Tasks.Task" /> completed successfully or has not yet thrown any exceptions, this will return <see langword="null" /> .
public int
Id
Gets an ID for this <see cref="T:System.Threading.Tasks.Task" /> instance.
public bool
IsCanceled
Gets whether this <see cref="T:System.Threading.Tasks.Task" /> instance has completed execution due to being canceled.
public bool
IsCompleted
Gets a value that indicates whether the task has completed.
public bool
IsCompletedSuccessfully
Gets whether the task ran to completion.
public bool
IsFaulted
Gets whether the <see cref="T:System.Threading.Tasks.Task" /> completed due to an unhandled exception.
public TaskStatus
Status
Gets the <see cref="T:System.Threading.Tasks.TaskStatus" /> of this task.

Methods

ConfigureAwait​(bool continueOnCapturedContext)
Configures an awaiter used to await this <see cref="T:System.Threading.Tasks.Task`1" /> .
Returns An object used to await this task.
continueOnCapturedContext true to attempt to marshal the continuation back to the original context captured; otherwise, false.
ConfigureAwait​(ConfigureAwaitOptions options)
Configures an awaiter used to await this <see cref="T:System.Threading.Tasks.Task" /> .
Returns An object used to await this task.
options Options used to configure how awaits on this task are performed.
public Task
ContinueWith​(Action<​Task<​TResult>, object> continuationAction, object state)
Creates a continuation that is passed state information and that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate is passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
public Task
ContinueWith​(Action<​Task<​TResult>, object> continuationAction, object state, CancellationToken cancellationToken)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
public Task
ContinueWith​(Action<​Task<​TResult>, object> continuationAction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task
ContinueWith​(Action<​Task<​TResult>, object> continuationAction, object state, TaskContinuationOptions continuationOptions)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task
ContinueWith​(Action<​Task<​TResult>, object> continuationAction, object state, TaskScheduler scheduler)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task
ContinueWith​(Action<​Task<​TResult>> continuationAction)
Creates a continuation that executes asynchronously when the target task completes.
Returns A new continuation task.
continuationAction An action to run when the antecedent <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task as an argument.
public Task
ContinueWith​(Action<​Task<​TResult>> continuationAction, CancellationToken cancellationToken)
Creates a cancelable continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation task.
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate is passed the completed task as an argument.
cancellationToken The cancellation token that is passed to the new continuation task.
public Task
ContinueWith​(Action<​Task<​TResult>> continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Creates a continuation that executes according the condition specified in <paramref name="continuationOptions" /> .
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run according the condition specified in <paramref name="continuationOptions" /> . When run, the delegate will be passed the completed task as an argument.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task
ContinueWith​(Action<​Task<​TResult>> continuationAction, TaskContinuationOptions continuationOptions)
Creates a continuation that executes according the condition specified in <paramref name="continuationOptions" /> .
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to according the condition specified in <paramref name="continuationOptions" /> . When run, the delegate will be passed the completed task as an argument.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task
ContinueWith​(Action<​Task<​TResult>> continuationAction, TaskScheduler scheduler)
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task as an argument.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, object, TNewResult> continuationFunction, object state)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, object, TNewResult> continuationFunction, object state, CancellationToken cancellationToken)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new task.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, object, TNewResult> continuationFunction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, object, TNewResult> continuationFunction, object state, TaskContinuationOptions continuationOptions)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, object, TNewResult> continuationFunction, object state, TaskScheduler scheduler)
Creates a continuation that executes when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, TNewResult> continuationFunction)
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task as an argument.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, TNewResult> continuationFunction, CancellationToken cancellationToken)
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new task.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, TNewResult> continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Creates a continuation that executes according the condition specified in <paramref name="continuationOptions" /> .
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run according the condition specified in <paramref name="continuationOptions" /> . When run, the delegate will be passed as an argument this completed task.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, TNewResult> continuationFunction, TaskContinuationOptions continuationOptions)
Creates a continuation that executes according the condition specified in <paramref name="continuationOptions" /> .
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run according the condition specified in <paramref name="continuationOptions" /> . When run, the delegate will be passed the completed task as an argument.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task<​TNewResult>
ContinueWith​(Func<​Task<​TResult>, TNewResult> continuationFunction, TaskScheduler scheduler)
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task as an argument.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
GetAwaiter​()
Gets an awaiter used to await this <see cref="T:System.Threading.Tasks.Task`1" /> .
Returns An awaiter instance.
public Task<​TResult>
WaitAsync​(CancellationToken cancellationToken)
Gets a <see cref="T:System.Threading.Tasks.Task`1" /> that will complete when this <see cref="T:System.Threading.Tasks.Task`1" /> completes or when the specified <see cref="T:System.Threading.CancellationToken" /> has cancellation requested.
Returns The <see cref="T:System.Threading.Tasks.Task`1" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> to monitor for a cancellation request.
public Task<​TResult>
WaitAsync​(TimeSpan timeout)
Gets a <see cref="T:System.Threading.Tasks.Task`1" /> that will complete when this <see cref="T:System.Threading.Tasks.Task`1" /> completes or when the specified timeout expires.
Returns The <see cref="T:System.Threading.Tasks.Task`1" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
public Task<​TResult>
WaitAsync​(TimeSpan timeout, CancellationToken cancellationToken)
Gets a <see cref="T:System.Threading.Tasks.Task`1" /> that will complete when this <see cref="T:System.Threading.Tasks.Task`1" /> completes, when the specified timeout expires, or when the specified <see cref="T:System.Threading.CancellationToken" /> has cancellation requested.
Returns The <see cref="T:System.Threading.Tasks.Task`1" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> to monitor for a cancellation request.
public Task<​TResult>
WaitAsync​(TimeSpan timeout, TimeProvider timeProvider)
Gets a <see cref="T:System.Threading.Tasks.Task`1" /> that will complete when this <see cref="T:System.Threading.Tasks.Task`1" /> completes or when the specified timeout expires.
Returns The <see cref="T:System.Threading.Tasks.Task`1" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
timeProvider The <see cref="T:System.TimeProvider" /> with which to interpret <paramref name="timeout" /> .
public Task<​TResult>
WaitAsync​(TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken)
Gets a <see cref="T:System.Threading.Tasks.Task`1" /> that will complete when this <see cref="T:System.Threading.Tasks.Task`1" /> completes, when the specified timeout expires, or when the specified <see cref="T:System.Threading.CancellationToken" /> has cancellation requested.
Returns The <see cref="T:System.Threading.Tasks.Task`1" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
timeProvider The <see cref="T:System.TimeProvider" /> with which to interpret <paramref name="timeout" /> .
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> to monitor for a cancellation request.
ConfigureAwait​(bool continueOnCapturedContext)
Inherited from Task
Configures an awaiter used to await this <see cref="T:System.Threading.Tasks.Task" /> .
Returns An object used to await this task.
continueOnCapturedContext <see langword="true" /> to attempt to marshal the continuation back to the original context captured; otherwise, <see langword="false" /> .
ConfigureAwait​(ConfigureAwaitOptions options)
Inherited from Task
Configures an awaiter used to await this <see cref="T:System.Threading.Tasks.Task" /> .
Returns An object used to await this task.
options Options used to configure how awaits on this task are performed.
public Task
ContinueWith​(Action<​Task, object> continuationAction, object state)
Inherited from Task
Creates a continuation that receives caller-supplied state information and executes when the target <see cref="T:System.Threading.Tasks.Task" /> completes.
Returns A new continuation task.
continuationAction An action to run when the task completes. When run, the delegate is passed the completed task and a caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
public Task
ContinueWith​(Action<​Task, object> continuationAction, object state, CancellationToken cancellationToken)
Inherited from Task
Creates a continuation that receives caller-supplied state information and a cancellation token and that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
public Task
ContinueWith​(Action<​Task, object> continuationAction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that receives caller-supplied state information and a cancellation token and that executes when the target <see cref="T:System.Threading.Tasks.Task" /> completes. The continuation executes based on a set of specified conditions and uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task
ContinueWith​(Action<​Task, object> continuationAction, object state, TaskContinuationOptions continuationOptions)
Inherited from Task
Creates a continuation that receives caller-supplied state information and executes when the target <see cref="T:System.Threading.Tasks.Task" /> completes. The continuation executes based on a set of specified conditions.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task
ContinueWith​(Action<​Task, object> continuationAction, object state, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that receives caller-supplied state information and executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes. The continuation uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation action.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task
ContinueWith​(Action<​Task> continuationAction)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task as an argument.
public Task
ContinueWith​(Action<​Task> continuationAction, CancellationToken cancellationToken)
Inherited from Task
Creates a continuation that receives a cancellation token and executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken The <see cref="P:System.Threading.Tasks.TaskFactory.CancellationToken" /> that will be assigned to the new continuation task.
public Task
ContinueWith​(Action<​Task> continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that executes when the target task competes according to the specified <see cref="T:System.Threading.Tasks.TaskContinuationOptions" /> . The continuation receives a cancellation token and uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run according to the specified <paramref name="continuationOptions" /> . When run, the delegate will be passed the completed task as an argument.
cancellationToken The <see cref="P:System.Threading.Tasks.TaskFactory.CancellationToken" /> that will be assigned to the new continuation task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task
ContinueWith​(Action<​Task> continuationAction, TaskContinuationOptions continuationOptions)
Inherited from Task
Creates a continuation that executes when the target task completes according to the specified <see cref="T:System.Threading.Tasks.TaskContinuationOptions" /> .
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run according to the specified <paramref name="continuationOptions" /> . When run, the delegate will be passed the completed task as an argument.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task
ContinueWith​(Action<​Task> continuationAction, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes. The continuation uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task" /> .
continuationAction An action to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task as an argument.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TResult>
ContinueWith​(Func<​Task, object, TResult> continuationFunction, object state)
Inherited from Task
Creates a continuation that receives caller-supplied state information and executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes and returns a value.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
public Task<​TResult>
ContinueWith​(Func<​Task, object, TResult> continuationFunction, object state, CancellationToken cancellationToken)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes and returns a value. The continuation receives caller-supplied state information and a cancellation token.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
public Task<​TResult>
ContinueWith​(Func<​Task, object, TResult> continuationFunction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that executes based on the specified task continuation options when the target <see cref="T:System.Threading.Tasks.Task" /> completes and returns a value. The continuation receives caller-supplied state information and a cancellation token and uses the specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> that will be assigned to the new continuation task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TResult>
ContinueWith​(Func<​Task, object, TResult> continuationFunction, object state, TaskContinuationOptions continuationOptions)
Inherited from Task
Creates a continuation that executes based on the specified task continuation options when the target <see cref="T:System.Threading.Tasks.Task" /> completes. The continuation receives caller-supplied state information.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task<​TResult>
ContinueWith​(Func<​Task, object, TResult> continuationFunction, object state, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes. The continuation receives caller-supplied state information and uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.
state An object representing data to be used by the continuation function.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TResult>
ContinueWith​(Func<​Task, TResult> continuationFunction)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task`1" /> completes and returns a value.
Returns A new continuation task.
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task`1" /> completes. When run, the delegate will be passed the completed task as an argument.
public Task<​TResult>
ContinueWith​(Func<​Task, TResult> continuationFunction, CancellationToken cancellationToken)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes and returns a value. The continuation receives a cancellation token.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken The <see cref="P:System.Threading.Tasks.TaskFactory.CancellationToken" /> that will be assigned to the new continuation task.
public Task<​TResult>
ContinueWith​(Func<​Task, TResult> continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that executes according to the specified continuation options and returns a value. The continuation is passed a cancellation token and uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run according to the specified <c>continuationOptions.</c> When run, the delegate will be passed the completed task as an argument.
cancellationToken The <see cref="P:System.Threading.Tasks.TaskFactory.CancellationToken" /> that will be assigned to the new continuation task.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public Task<​TResult>
ContinueWith​(Func<​Task, TResult> continuationFunction, TaskContinuationOptions continuationOptions)
Inherited from Task
Creates a continuation that executes according to the specified continuation options and returns a value.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run according to the condition specified in <paramref name="continuationOptions" /> . When run, the delegate will be passed the completed task as an argument.
continuationOptions Options for when the continuation is scheduled and how it behaves. This includes criteria, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.OnlyOnCanceled" /> , as well as execution options, such as <see cref="F:System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously" /> .
public Task<​TResult>
ContinueWith​(Func<​Task, TResult> continuationFunction, TaskScheduler scheduler)
Inherited from Task
Creates a continuation that executes asynchronously when the target <see cref="T:System.Threading.Tasks.Task" /> completes and returns a value. The continuation uses a specified scheduler.
Returns A new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
continuationFunction A function to run when the <see cref="T:System.Threading.Tasks.Task" /> completes. When run, the delegate will be passed the completed task as an argument.
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> to associate with the continuation task and to use for its execution.
public void
Dispose​()
Inherited from Task
Releases all resources used by the current instance of the <see cref="T:System.Threading.Tasks.Task" /> class.
protected void
Dispose​(bool disposing)
Inherited from Task
Disposes the <see cref="T:System.Threading.Tasks.Task" /> , releasing all of its unmanaged resources.
disposing A Boolean value that indicates whether this method is being called due to a call to <see cref="M:System.Threading.Tasks.Task.Dispose" /> .
GetAwaiter​()
Inherited from Task
Gets an awaiter used to await this <see cref="T:System.Threading.Tasks.Task" /> .
Returns An awaiter instance.
public void
RunSynchronously​()
Inherited from Task
Runs the <see cref="T:System.Threading.Tasks.Task" /> synchronously on the current <see cref="T:System.Threading.Tasks.TaskScheduler" /> .
public void
RunSynchronously​(TaskScheduler scheduler)
Inherited from Task
Runs the <see cref="T:System.Threading.Tasks.Task" /> synchronously on the <see cref="T:System.Threading.Tasks.TaskScheduler" /> provided.
scheduler The scheduler on which to attempt to run this task inline.
public void
Start​()
Inherited from Task
Starts the <see cref="T:System.Threading.Tasks.Task" /> , scheduling it for execution to the current <see cref="T:System.Threading.Tasks.TaskScheduler" /> .
public void
Start​(TaskScheduler scheduler)
Inherited from Task
Starts the <see cref="T:System.Threading.Tasks.Task" /> , scheduling it for execution to the specified <see cref="T:System.Threading.Tasks.TaskScheduler" /> .
scheduler The <see cref="T:System.Threading.Tasks.TaskScheduler" /> with which to associate and execute this task.
public void
Wait​()
Inherited from Task
Waits for the <see cref="T:System.Threading.Tasks.Task" /> to complete execution.
public bool
Wait​(int millisecondsTimeout)
Inherited from Task
Waits for the <see cref="T:System.Threading.Tasks.Task" /> to complete execution within a specified number of milliseconds.
Returns <see langword="true" /> if the <see cref="T:System.Threading.Tasks.Task" /> completed execution within the allotted time; otherwise, <see langword="false" /> .
millisecondsTimeout The number of milliseconds to wait, or <see cref="F:System.Threading.Timeout.Infinite" /> (-1) to wait indefinitely.
public bool
Wait​(int millisecondsTimeout, CancellationToken cancellationToken)
Inherited from Task
Waits for the <see cref="T:System.Threading.Tasks.Task" /> to complete execution. The wait terminates if a timeout interval elapses or a cancellation token is canceled before the task completes.
Returns <see langword="true" /> if the <see cref="T:System.Threading.Tasks.Task" /> completed execution within the allotted time; otherwise, <see langword="false" /> .
millisecondsTimeout The number of milliseconds to wait, or <see cref="F:System.Threading.Timeout.Infinite" /> (-1) to wait indefinitely.
cancellationToken A cancellation token to observe while waiting for the task to complete.
public void
Wait​(CancellationToken cancellationToken)
Inherited from Task
Waits for the <see cref="T:System.Threading.Tasks.Task" /> to complete execution. The wait terminates if a cancellation token is canceled before the task completes.
cancellationToken A cancellation token to observe while waiting for the task to complete.
public bool
Wait​(TimeSpan timeout)
Inherited from Task
Waits for the <see cref="T:System.Threading.Tasks.Task" /> to complete execution within a specified time interval.
Returns <see langword="true" /> if the <see cref="T:System.Threading.Tasks.Task" /> completed execution within the allotted time; otherwise, <see langword="false" /> .
timeout A <see cref="T:System.TimeSpan" /> that represents the number of milliseconds to wait, or a <see cref="T:System.TimeSpan" /> that represents -1 milliseconds to wait indefinitely.
public bool
Wait​(TimeSpan timeout, CancellationToken cancellationToken)
Inherited from Task
Waits for the <see cref="T:System.Threading.Tasks.Task" /> to complete execution.
Returns <see langword="true" /> if the <see cref="T:System.Threading.Tasks.Task" /> completed execution within the allotted time; otherwise, <see langword="false" /> .
timeout The time to wait, or <see cref="F:System.Threading.Timeout.InfiniteTimeSpan" /> to wait indefinitely
cancellationToken A <see cref="P:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.
public Task
WaitAsync​(CancellationToken cancellationToken)
Inherited from Task
Gets a <see cref="T:System.Threading.Tasks.Task" /> that will complete when this <see cref="T:System.Threading.Tasks.Task" /> completes or when the specified <see cref="P:System.Threading.CancellationToken" /> has cancellation requested.
Returns The <see cref="T:System.Threading.Tasks.Task" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
cancellationToken The <see cref="P:System.Threading.CancellationToken" /> to monitor for a cancellation request.
public Task
WaitAsync​(TimeSpan timeout)
Inherited from Task
Gets a <see cref="T:System.Threading.Tasks.Task" /> that will complete when this <see cref="T:System.Threading.Tasks.Task" /> completes or when the specified timeout expires.
Returns The <see cref="T:System.Threading.Tasks.Task" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
public Task
WaitAsync​(TimeSpan timeout, CancellationToken cancellationToken)
Inherited from Task
Gets a <see cref="T:System.Threading.Tasks.Task" /> that will complete when this <see cref="T:System.Threading.Tasks.Task" /> completes, when the specified timeout expires, or when the specified <see cref="P:System.Threading.CancellationToken" /> has cancellation requested.
Returns The <see cref="T:System.Threading.Tasks.Task" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
cancellationToken The <see cref="P:System.Threading.CancellationToken" /> to monitor for a cancellation request.
public Task
WaitAsync​(TimeSpan timeout, TimeProvider timeProvider)
Inherited from Task
Gets a <see cref="T:System.Threading.Tasks.Task" /> that will complete when this <see cref="T:System.Threading.Tasks.Task" /> completes or when the specified timeout expires.
Returns The <see cref="T:System.Threading.Tasks.Task" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
timeProvider The <see cref="T:System.TimeProvider" /> with which to interpret <paramref name="timeout" /> .
public Task
WaitAsync​(TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken)
Inherited from Task
Gets a <see cref="T:System.Threading.Tasks.Task" /> that will complete when this <see cref="T:System.Threading.Tasks.Task" /> completes, when the specified timeout expires, or when the specified <see cref="T:System.Threading.CancellationToken" /> has cancellation requested.
Returns The <see cref="T:System.Threading.Tasks.Task" /> representing the asynchronous wait. It may or may not be the same instance as the current instance.
timeout The timeout after which the <see cref="T:System.Threading.Tasks.Task" /> should be faulted with a <see cref="T:System.TimeoutException" /> if it hasn't otherwise completed.
timeProvider The <see cref="T:System.TimeProvider" /> with which to interpret <paramref name="timeout" /> .
cancellationToken The <see cref="T:System.Threading.CancellationToken" /> to monitor for a cancellation request.
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.