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

System.Threading.Tasks.TaskCompletionSource<TResult>

public class TaskCompletionSource<TResult>
Represents the producer side of a Task{TResult} unbound to a delegate, providing access to the consumer side through the Task property.
public Task<TResult> Task { get; }

Gets the Task{TResult} created by this TaskCompletionSource<T>.

Creates a TaskCompletionSource<T>.

public TaskCompletionSource(TaskCreationOptions creationOptions)

Creates a TaskCompletionSource<T> with the specified options.

public TaskCompletionSource(object state)

Creates a TaskCompletionSource<T> with the specified state.

public TaskCompletionSource(object state, TaskCreationOptions creationOptions)

Creates a TaskCompletionSource<T> with the specified state and options.

public void SetCanceled()

Transitions the underlying Task{TResult} into the CanceledCanceled state.

public void SetException(Exception exception)

Transitions the underlying Task{TResult} into the FaultedFaulted state.

public void SetException(IEnumerable<Exception> exceptions)

Transitions the underlying Task{TResult} into the FaultedFaulted state.

public void SetResult(TResult result)

Transitions the underlying Task{TResult} into the RanToCompletionRanToCompletion state.

public bool TrySetCanceled()

Attempts to transition the underlying Task{TResult} into the CanceledCanceled state.

public bool TrySetException(Exception exception)

Attempts to transition the underlying Task{TResult} into the FaultedFaulted state.

public bool TrySetException(IEnumerable<Exception> exceptions)

Attempts to transition the underlying Task{TResult} into the FaultedFaulted state.

public bool TrySetResult(TResult result)

Attempts to transition the underlying Task{TResult} into the RanToCompletionRanToCompletion state.