Share via


TplExtensions Class

Definition

Extensions to the Task Parallel Library.

public ref class TplExtensions abstract sealed
public ref class TplExtensions abstract sealed
class TplExtensions abstract sealed
public static class TplExtensions
type TplExtensions = class
Public Module TplExtensions
Inheritance
TplExtensions

Fields

CanceledTask
Obsolete.

A task that is already canceled.

CompletedTask
Obsolete.

A singleton completed task.

FalseTask

A completed task with a false result.

TrueTask

A completed task with a true result.

Methods

AppendAction(Task, Action, TaskContinuationOptions, CancellationToken)

Schedules some action for execution at the conclusion of a task, regardless of the task's outcome.

ApplyResultTo<T>(Task, TaskCompletionSource<T>)

Applies one task's results to another.

ApplyResultTo<T>(Task<T>, TaskCompletionSource<T>)

Applies one task's results to another.

AttachToParent(Task)

Creates a task that is attached to the parent task, but produces the same result as an existing task.

AttachToParent<T>(Task<T>)

Creates a task that is attached to the parent task, but produces the same result as an existing task.

FollowCancelableTaskToCompletion<T>(Func<Task<T>>, CancellationToken, TaskCompletionSource<T>)

Gets a task that will eventually produce the result of another task, when that task finishes. If that task is instead canceled, its successor will be followed for its result, iteratively.

Forget(Task)

Consumes a task and doesn't do anything with it. Useful for fire-and-forget calls to async methods within async methods.

Forget(ValueTask)

Consumes a ValueTask and allows it to be recycled, if applicable. Useful for fire-and-forget calls to async methods within async methods. NOTE: APIs should not generally return ValueTask if callers aren't 99.9999% likely to await the result immediately.

Forget<T>(ValueTask<T>)

Consumes a ValueTask and allows it to be recycled, if applicable. Useful for fire-and-forget calls to async methods within async methods. NOTE: APIs should not generally return ValueTask<TResult> if callers aren't 99.9999% likely to await the result immediately.

InvokeAsync(AsyncEventHandler, Object, EventArgs)

Invokes asynchronous event handlers, returning a task that completes when all event handlers have been invoked. Each handler is fully executed (including continuations) before the next handler in the list is invoked.

InvokeAsync<TEventArgs>(AsyncEventHandler<TEventArgs>, Object, TEventArgs)

Invokes asynchronous event handlers, returning a task that completes when all event handlers have been invoked. Each handler is fully executed (including continuations) before the next handler in the list is invoked.

NoThrowAwaitable(Task, Boolean)

Returns an awaitable for the specified task that will never throw, even if the source task faults or is canceled.

NoThrowAwaitable(ValueTask, Boolean)

Returns an awaitable for the specified task that will never throw, even if the source task faults or is canceled.

NoThrowAwaitable<TResult>(ValueTask<TResult>, Boolean)

Returns an awaitable for the specified task that will never throw, even if the source task faults or is canceled.

ToApm(Task, AsyncCallback, Object)

Converts a TPL task to the APM Begin-End pattern.

ToApm<TResult>(Task<TResult>, AsyncCallback, Object)

Converts a TPL task to the APM Begin-End pattern.

ToTask(WaitHandle, Int32, CancellationToken)

Creates a TPL Task that returns true when a WaitHandle is signaled or returns false if a timeout occurs first.

WaitWithoutInlining(Task)

Wait on a task without possibly inlining it to the current thread.

WithTimeout(Task, TimeSpan)

Returns a task that completes as the original task completes or when a timeout expires, whichever happens first.

WithTimeout<T>(Task<T>, TimeSpan)

Returns a task that completes as the original task completes or when a timeout expires, whichever happens first.

Applies to

Thread Safety

This type is thread-safe for all members.