已通过await等待的Task其IsCompleted属性是否可能返回false?
task.IsCompleted be false after awaiting the task? Short answer: Absolutely not — once you've awaited a Task, it is guaranteed to be in a completed state, so task.IsCompleted will always return true at that point.
Let me break this down for you:
How await works
When you await a Task, the runtime will pause execution of the current method until the task reaches one of its final states: RanToCompletion, Faulted, or Canceled. It doesn't matter if the task completes synchronously (right when you call DoSomethingAsync) or asynchronously later — the await keyword ensures your code doesn't proceed past that line until the task is done.
What this means for your code
Your original code:
Task task = DoSomethingAsync( someObject ); await task.ConfigureAwait( false ); if ( task.IsCompleted ){ ... }
That if check is completely redundant. After await task.ConfigureAwait(false);, task is guaranteed to be completed, so the condition will always evaluate to true.
Safe code replacement
You can absolutely replace this with:
await DoSomethingAsync( someObject ).ConfigureAwait( false );
And remove the if statement entirely. This code behaves exactly the same as your original, but is cleaner and avoids unnecessary checks.
Confirming with the IsCompleted documentation
As you noted, the docs state:
如果任务已完成(即任务处于RanToCompletion、Faulted或Canceled这三种最终状态之一),则返回true;否则返回false。
Since await only proceeds when the task is in one of these three final states, IsCompleted can't be false after awaiting. There's no scenario where this could happen — it's a fundamental guarantee of how async/await works in .NET.
内容的提问来源于stack exchange,提问作者Mong Zhu

