Muokkaa

Jaa


TaskCompletionSource<TResult>.TrySetException Method

Definition

Attempts to transition the underlying Task<TResult> object into the Faulted state.

Overloads

TrySetException(IEnumerable<Exception>)

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

TrySetException(Exception)

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

TrySetException(IEnumerable<Exception>)

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

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

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

Parameters

exceptions
IEnumerable<Exception>

The collection of exceptions to bind to this Task<TResult>.

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<TResult> 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

Attempts to transition the underlying Task<TResult> 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<TResult>.

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<TResult> is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

See also

Applies to