C# Interview Question #143
What is ConfigureAwait in C#?
Advanced Async, Parallelism & Threading Senior Advanced
Quick Interview Answer
ConfigureAwait controls whether an await should attempt to continue on the captured synchronization context.
Detailed Explanation
ConfigureAwait controls whether an await should attempt to continue on the captured synchronization context.
In classic UI applications, capturing the synchronization context can be important because continuation code may need to return to the UI thread.
ASP.NET Core does not install the classic request SynchronizationContext, so ConfigureAwait(false) generally does not provide the same behavioral benefit there as it historically did in older ASP.NET or desktop UI applications.
ConfigureAwait remains particularly relevant in reusable libraries that should not depend on a caller's context.
Code Example
await SomeOperationAsync()
.ConfigureAwait(false);