Bewerken

Delen via


TaskCompletionSource<TResult>.TrySetFromTask Method

Definition

Attempts to transition the underlying Task<TResult> into the same completion state as the specified completedTask.

public:
 bool TrySetFromTask(System::Threading::Tasks::Task<TResult> ^ completedTask);
public bool TrySetFromTask (System.Threading.Tasks.Task<TResult> completedTask);
member this.TrySetFromTask : System.Threading.Tasks.Task<'Result> -> bool
Public Function TrySetFromTask (completedTask As Task(Of TResult)) As Boolean

Parameters

completedTask
Task<TResult>

The completed task whose completion status (including result, exception, or cancellation information) should be copied to the underlying task.

Returns

true if the operation was successful; otherwise, false.

Exceptions

completedTask is null.

completedTask is not completed.

Remarks

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

Applies to