4 ms·
> Do you remember ConfigureAwait(false)? What makes you think that this no longer applies? It still does to my knowledge. The page you linked to has a section
by quietbritishjim 4y ago
> Do you remember ConfigureAwait(false)?
What makes you think that this no longer applies? It still does to my knowledge. The page you linked to has a section for it that just says "TBD".
- serguzest 4y agoI actually have no idea if it still applies, but I haven't seen code that uses it for a long time. Maybe it was important for desktop apps?
- avsteele 4y agoIt's important to have ConfigureAwait(true) (the default) any time you need the continuation to be on the same thread. This is used/needed for many UI frameworks (WPF), which is why it is the default. Otherwise you should use (false) for performance reasons.
- foepys 4y agoYes, this is very important. I experienced deadlocks in ASP.NET Core 2.1 when I connected a legacy application to the web with it and the developers of Microsoft.AspNetCore.Mvc.Formatters.Json forgot to add .ConfigureAwait(false) to a async call into Newtonsoft.Json. This was easily fixed by writing a small warper around the JsonInputFormatter but it shows how important ConfigureAwait is. When writing a library for anything netstandard, always put ConfigureAwait(false) after each async call where it is not mandatory to return to the same thread again.
- SideburnsOfDoom 4y ago> It's important to have ConfigureAwait(true) ... Otherwise you should use (false) This is not universal. In modern ASP.NET core (i.e. web services), ConfigureAwait does nothing and is not recommended. I can confidently say that I don't want it in any of the code that I work on. We can make blanket statements, but clearly we do different things using different patterns and one size does not fit all. https://stackoverflow.com/questions/42053135/configureawaitfalse-relevant-in-asp-net-core https://stackoverflow.com/questions/42053135/configureawaitf...
- SideburnsOfDoom 4y agoConfigureAwait (mostly) no longer applies. You might want it in .NET 4.x apps, and in libraries that might be used in them. Or in apps with a "UI thread" - i.e. desktop GUIs. In modern ASP .NET, it does nothing, so we don't use it. https://stackoverflow.com/questions/42053135/configureawaitfalse-relevant-in-asp-net-core https://stackoverflow.com/questions/42053135/configureawaitf...
- chrisoverzero 4y agoYour advice is correct for ASP.NET Core (the web application framework), but not for all of .NET (Core or suffixless).
- SideburnsOfDoom 4y agoThanks, I have edited. Even inside .NET different people work on very different things, and my niche might not be your niche.
- sebazzz 4y agoNot even (fully) for ASP.NET Core, as Blazor Server does use a SynchronizationContext.