TaskCompletionSource : When to use SetResult() versus TrySetResult(), etc
问题 I'm trying to wrap my head around the TPL, the new async / await features in C# 5, and the mysteries of TaskCompletionSource . One thing that isn't clear to me is when to use SetResult , SetException , and SetCancel versus TrySetResult , TrySetException and TrySetCancel . This is what MSDN has to say: This operation will return false if the Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled. This method also returns false if the underlying Task has already