TaskCompletionSourceExtensionsTrySetFromTaskTSource, TResult Method (TaskCompletionSourceTResult, TaskTSource) |
Namespace: Rackspace.Threading
public static bool TrySetFromTask<TSource, TResult>( this TaskCompletionSource<TResult> taskCompletionSource, Task<TSource> task ) where TSource : TResult
if the operation was successful.
-or-
if the operation was unsuccessful or the object has already been disposed.
Exception | Condition |
---|---|
ArgumentNullException |
If taskCompletionSource is . -or- If task is . |
This method will return if the TaskTResult provided by taskCompletionSource is already in one of the three final states: RanToCompletion, Faulted, or Canceled. This method also returns if the underlying TaskTResult has already been disposed.
If task is in the RanToCompletion state, the result of the task is assigned to the TaskCompletionSourceTResult using the TrySetResult(TResult) method.
If task is in the Faulted state, the unwrapped exceptions are bound to the TaskCompletionSourceTResult using the TrySetException(IEnumerableException) method.
If task is in the Canceled state, the TaskCompletionSourceTResult is transitioned to the Canceled state using the TrySetCanceled method.