Language

TaskCompletionSource.TrySetException Method

Definition

Attempts to transition the underlying Task object into the Faulted state.

Overloads

Name Description
TrySetException(IEnumerable)

Attempts to transition the underlying Task into the Faulted state and binds a collection of exception objects to it.

TrySetException(Exception)

Attempts to transition the underlying Task into the Faulted state and binds it to a specified exception.

TrySetException(IEnumerable)

Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs

Attempts to transition the underlying Task into the Faulted state and binds a collection of exception objects to it.

public:
 bool TrySetException(System::Collections::Generic::IEnumerable ^ exceptions);
public bool TrySetException(System.Collections.Generic.IEnumerable exceptions);
member this.TrySetException : seq -> bool
Public Function TrySetException (exceptions As IEnumerable(Of Exception)) As Boolean

Parameters

exceptions
IEnumerable<Exception>

The collection of exceptions to bind to this Task.

Returns

true if the operation was successful; otherwise, false.

Exceptions

The Task was disposed.

The exceptions argument is null.

There are one or more null elements in exceptions.

-or-

The exceptions collection is empty.

Remarks

This operation will return false if the Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

See also

Applies to

TrySetException(Exception)

Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs
Source:
TaskCompletionSource_T.cs

Attempts to transition the underlying Task into the Faulted state and binds it to a specified exception.

public:
 bool TrySetException(Exception ^ exception);
public bool TrySetException(Exception exception);
member this.TrySetException : Exception -> bool
Public Function TrySetException (exception As Exception) As Boolean

Parameters

exception
Exception

The exception to bind to this Task.

Returns

true if the operation was successful; otherwise, false.

Exceptions

The Task was disposed.

The exception argument is null.

Remarks

This operation will return false if the Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

See also

Applies to