System.Threading.Tasks.TaskCompletionSource<TResult>.TrySetException Method

Attempts to transition the underlying System.Threading.Tasks.Task`1 into the TaskStatus.Faulted state.

Syntax

public bool TrySetException (IEnumerable<Exception> exceptions)

Parameters

exceptions
The collection of exceptions to bind to this System.Threading.Tasks.Task`1.

Returns

True if the operation was successful; otherwise, false.

Remarks

This operation will return false if the System.Threading.Tasks.Task`1 is already in one of the three final states: TaskStatus.RanToCompletion, TaskStatus.Faulted, or TaskStatus.Canceled.

Requirements

Namespace: System.Threading.Tasks
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0