I found this piece of code:
Task task = DoSomethingAsync( someObject );
await task.ConfigureAwait( false );
if ( task.IsCompleted ){ ... }
I wonder if I can safely replace it with
await DoSomethingAsync( someObject ).ConfigureAwait( false );
and drop the if clause.
My question: can task.IsCompleted ever be false when an awaited task has returned?
The documentation of IsCompleted tells us:
trueif the task has completed (that is, the task is in one of the three final states: RanToCompletion, Faulted, or Canceled); otherwise,false.
I looked up the possible states but it is still not clear to me which of the states is possible when the awaited task hast returned.
Please help me to shed light on this matter. Thanx in advace.