TaskCompletionSourceExtensions.SetFromTask<TSource, TResult> Method (TaskCompletionSource<TResult>, Task<TSource>) |
Namespace: Rackspace.Threading
public static void SetFromTask<TSource, TResult>( this TaskCompletionSource<TResult> taskCompletionSource, Task<TSource> task ) where TSource : TResult
Exception | Condition |
---|---|
ArgumentNullException |
If taskCompletionSource is null. -or- If task is null. |
ObjectDisposedException |
If the underlying Task<TResult> of taskCompletionSource was disposed. |
InvalidOperationException |
If the underlying Task<TResult> produced by taskCompletionSource is already in one of the three final states: RanToCompletion, Faulted, or Canceled. |
If task is in the RanToCompletion state, the result of the task is assigned to the TaskCompletionSource<TResult> using the SetResult(TResult) method.
If task is in the Faulted state, the unwrapped exceptions are bound to the TaskCompletionSource<TResult> using the SetException(IEnumerable<Exception>) method.
If task is in the Canceled state, the TaskCompletionSource<TResult> is transitioned to the Canceled state using the SetCanceled() method.