I use async/await extensively almost everywehrre. But I saw it enough in a few places that brought my attension.
What is the benefit of await task.ConfigureAwait(false) in C#?
Does turning on or off the flag affect the performance of a task? Why setting this continueOnCapturedContext to off recommended and why is it not false by default then?
This might be flagged as duplicate, but still couldn't come up with a solid and simple answer.
Task.ResultorTask.GetAwaiter().GetResult()(i.e. you have code that will block its thread ifTaskis incomplete) then you cannot rely onConfigureAwait(false)as a workaround: you need to useawait Taskand ditch.Resultetc.ConfigureAwait(false)even once, then you are out of luck, and yourConfigureAwait(false)is useless in preventing deadlocks. I believe the point he was trying to make is that the purpose ofConfigureAwait(false)is not to prevent deadlocks to begin with, which is further supported by blog.stephencleary.com/2023/11/configureawait-in-net-8.html ("That’s not its purpose, and it’s a questionable solution at best").