<PackageReference Include="Microsoft.Bcl" Version="1.1.7" />

System.Threading.Tasks.Task

Represents an asynchronous operation.
public static int? CurrentId { get; }

Returns the unique ID of the currently executing TaskTask.

public static TaskFactory Factory { get; }

Provides access to factory methods for creating Task and Task<T> instances.

public object AsyncState { get; }

Gets the state object supplied when the TaskTask was created, or null if none was supplied.

Gets the TaskCreationOptionsTaskCreationOptions used to create this task.

public AggregateException Exception { get; }

Gets the AggregateExceptionException that caused the TaskTask to end prematurely. If the TaskTask completed successfully or has not yet thrown any exceptions, this will return null.

public int Id { get; }

Gets a unique ID for this TaskTask instance.

public bool IsCanceled { get; }

Gets whether this TaskTask instance has completed execution due to being canceled.

public bool IsCompleted { get; }

Gets whether this TaskTask has completed.

public bool IsFaulted { get; }

Gets whether the Task completed due to an unhandled exception.

public TaskStatus Status { get; }

Gets the TaskStatusTaskStatus of this Task.

public Task(Action action)

Initializes a new Task with the specified action.

public Task(Action action, CancellationToken cancellationToken)

Initializes a new Task with the specified action and CancellationTokenCancellationToken.

public Task(Action action, TaskCreationOptions creationOptions)

Initializes a new Task with the specified action and creation options.

public Task(Action action, CancellationToken cancellationToken, TaskCreationOptions creationOptions)

Initializes a new Task with the specified action and creation options.

public Task(Action<object> action, object state)

Initializes a new Task with the specified action and state.

public Task(Action<object> action, object state, CancellationToken cancellationToken)

Initializes a new Task with the specified action, state, snd options.

public Task(Action<object> action, object state, TaskCreationOptions creationOptions)

Initializes a new Task with the specified action, state, snd options.

public Task(Action<object> action, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)

Initializes a new Task with the specified action, state, snd options.

public static void WaitAll(Task[] tasks)

Waits for all of the provided Task objects to complete execution.

public static bool WaitAll(Task[] tasks, TimeSpan timeout)

Waits for all of the provided Task objects to complete execution.

public static bool WaitAll(Task[] tasks, int millisecondsTimeout)

Waits for all of the provided Task objects to complete execution.

public static void WaitAll(Task[] tasks, CancellationToken cancellationToken)

Waits for all of the provided Task objects to complete execution.

public static bool WaitAll(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken)

Waits for all of the provided Task objects to complete execution.

public static int WaitAny(Task[] tasks)

Waits for any of the provided Task objects to complete execution.

public static int WaitAny(Task[] tasks, TimeSpan timeout)

Waits for any of the provided Task objects to complete execution.

public static int WaitAny(Task[] tasks, CancellationToken cancellationToken)

Waits for any of the provided Task objects to complete execution.

public static int WaitAny(Task[] tasks, int millisecondsTimeout)

Waits for any of the provided Task objects to complete execution.

public static int WaitAny(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken)

Waits for any of the provided Task objects to complete execution.

public Task ContinueWith(Action<Task> continuationAction)

Creates a continuation that executes when the target Task completes.

public Task ContinueWith(Action<Task> continuationAction, CancellationToken cancellationToken)

Creates a continuation that executes when the target Task completes.

public Task ContinueWith(Action<Task> continuationAction, TaskScheduler scheduler)

Creates a continuation that executes when the target Task completes.

public Task ContinueWith(Action<Task> continuationAction, TaskContinuationOptions continuationOptions)

Creates a continuation that executes when the target Task completes.

public Task ContinueWith(Action<Task> continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)

Creates a continuation that executes when the target Task completes.

public Task<TResult> ContinueWith<TResult>(Func<Task, TResult> continuationFunction)

Creates a continuation that executes when the target Task completes.

public Task<TResult> ContinueWith<TResult>(Func<Task, TResult> continuationFunction, CancellationToken cancellationToken)

Creates a continuation that executes when the target Task completes.

public Task<TResult> ContinueWith<TResult>(Func<Task, TResult> continuationFunction, TaskScheduler scheduler)

Creates a continuation that executes when the target Task completes.

public Task<TResult> ContinueWith<TResult>(Func<Task, TResult> continuationFunction, TaskContinuationOptions continuationOptions)

Creates a continuation that executes when the target Task completes.

public Task<TResult> ContinueWith<TResult>(Func<Task, TResult> continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)

Creates a continuation that executes when the target Task completes.

public void RunSynchronously()

Runs the Task synchronously on the current TaskSchedulerTaskScheduler.

public void RunSynchronously(TaskScheduler scheduler)

Runs the Task synchronously on the TaskSchedulerscheduler provided.

public void Start()

Starts the Task, scheduling it for execution to the current TaskSchedulerTaskScheduler.

public void Start(TaskScheduler scheduler)

Starts the Task, scheduling it for execution to the specified TaskSchedulerTaskScheduler.

public void Wait()

Waits for the Task to complete execution.

public bool Wait(TimeSpan timeout)

Waits for the Task to complete execution.

public void Wait(CancellationToken cancellationToken)

Waits for the Task to complete execution.

public bool Wait(int millisecondsTimeout)

Waits for the Task to complete execution.

public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)

Waits for the Task to complete execution.