Share via


TplExtensions.FollowCancelableTaskToCompletion<T> Method

Definition

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.

public static System.Threading.Tasks.Task<T> FollowCancelableTaskToCompletion<T> (Func<System.Threading.Tasks.Task<T>> taskToFollow, System.Threading.CancellationToken ultimateCancellation, System.Threading.Tasks.TaskCompletionSource<T> taskThatFollows = default);
public static System.Threading.Tasks.Task<T> FollowCancelableTaskToCompletion<T> (Func<System.Threading.Tasks.Task<T>> taskToFollow, System.Threading.CancellationToken ultimateCancellation, System.Threading.Tasks.TaskCompletionSource<T>? taskThatFollows = default);
static member FollowCancelableTaskToCompletion : Func<System.Threading.Tasks.Task<'T>> * System.Threading.CancellationToken * System.Threading.Tasks.TaskCompletionSource<'T> -> System.Threading.Tasks.Task<'T>
Public Function FollowCancelableTaskToCompletion(Of T) (taskToFollow As Func(Of Task(Of T)), ultimateCancellation As CancellationToken, Optional taskThatFollows As TaskCompletionSource(Of T) = Nothing) As Task(Of T)

Type Parameters

T

The type of value returned by the task.

Parameters

taskToFollow
Func<Task<T>>

The task whose result should be returned by the following task.

ultimateCancellation
CancellationToken

A token whose cancellation signals that the following task should be cancelled.

taskThatFollows
TaskCompletionSource<T>

The TaskCompletionSource whose task is to follow. Leave at null for a new task to be created.

Returns

Task<T>

The following task.

Applies to