編輯

共用方式為


TaskCompletionSource.TrySetResult Method

Definition

Attempts to transition the underlying Task into the RanToCompletion state.

public:
 bool TrySetResult();
public bool TrySetResult ();
member this.TrySetResult : unit -> bool
Public Function TrySetResult () As Boolean

Returns

true if the operation was successful; otherwise, false.

Remarks

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

Applies to