<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.166" />

TaskEx

public static class TaskEx
Provides methods for creating and manipulating tasks.
public static Task Delay(int dueTime)

Starts a Task that will complete after the specified due time.

public static Task Delay(TimeSpan dueTime)

Starts a Task that will complete after the specified due time.

public static Task Delay(TimeSpan dueTime, CancellationToken cancellationToken)

Starts a Task that will complete after the specified due time.

public static Task Delay(int dueTime, CancellationToken cancellationToken)

Starts a Task that will complete after the specified due time.

public static Task<TResult> FromResult<TResult>(TResult result)

Creates an already completed Task<T> from the specified result.

public static Task Run(Action action)

Creates a task that runs the specified action.

public static Task Run(Action action, CancellationToken cancellationToken)

Creates a task that runs the specified action.

public static Task<TResult> Run<TResult>(Func<TResult> function)

Creates a task that runs the specified function.

public static Task<TResult> Run<TResult>(Func<TResult> function, CancellationToken cancellationToken)

Creates a task that runs the specified function.

public static Task Run(Func<Task> function)

Creates a task that runs the specified function.

public static Task Run(Func<Task> function, CancellationToken cancellationToken)

Creates a task that runs the specified function.

public static Task<TResult> Run<TResult>(Func<Task<TResult>> function)

Creates a task that runs the specified function.

public static Task<TResult> Run<TResult>(Func<Task<TResult>> function, CancellationToken cancellationToken)

Creates a task that runs the specified function.

public static Task WhenAll(Task[] tasks)

Creates a Task that will complete only when all of the provided collection of Tasks has completed.

public static Task<TResult[]> WhenAll<TResult>(Task<TResult>[] tasks)

Creates a Task that will complete only when all of the provided collection of Tasks has completed.

public static Task WhenAll(IEnumerable<Task> tasks)

Creates a Task that will complete only when all of the provided collection of Tasks has completed.

public static Task<TResult[]> WhenAll<TResult>(IEnumerable<Task<TResult>> tasks)

Creates a Task that will complete only when all of the provided collection of Tasks has completed.

public static Task<Task> WhenAny(Task[] tasks)

Creates a Task that will complete when any of the tasks in the provided collection completes.

public static Task<Task> WhenAny(IEnumerable<Task> tasks)

Creates a Task that will complete when any of the tasks in the provided collection completes.

public static Task<Task<TResult>> WhenAny<TResult>(Task<TResult>[] tasks)

Creates a Task that will complete when any of the tasks in the provided collection completes.

public static Task<Task<TResult>> WhenAny<TResult>(IEnumerable<Task<TResult>> tasks)

Creates a Task that will complete when any of the tasks in the provided collection completes.

public static YieldAwaitable Yield()

Creates an awaitable that asynchronously yields back to the current context when awaited.