I am working on ASP.NET Web API 2 Application. In the application we are using for every async request:
ConfigureAwait(false);
I cannot really understand what does it mean. I looked on the internet but still don't understand what it exactly does?
I am working on ASP.NET Web API 2 Application. In the application we are using for every async request:
ConfigureAwait(false);
I cannot really understand what does it mean. I looked on the internet but still don't understand what it exactly does?
 
    
     
    
    To understand it, you need to understand what is Synchronization Context and Threading Models.
From practical perspective lets take a look at canonical example. You are developing GUI application (Win Forms or WPF). You have dedicated UI thread. You must update UI on UI thread and do not block UI thread by calculations or waiting some response.
ConfigureAwait have sense with async/await. By default, code after await will run on captured UI thread,
await DoAsync();
//UI updating code goes here. Will run on UI thread
Code after await will run on thread pool, if you specify ConfigureAwait(false)
await DoAsync().ConfigureAwait(false);
//CPU intensive operation. Will run on thread pool
You do not have dedicated UI thread, as far as you have ASP.NET application. But Synchronization Context is important too. Understanding the SynchronizationContext in ASP.NET will give you details.
