Configure Awaiter in C# Notes

Notes

  • Link to the Microsoft source documentation.
  • Stack Overflow post with a bunch of interesting information, summarized below.

Using ConfigureAwait(false) means that following code may or may not run on the same thread as before. If there is code that accesses the UI after such a call, it might not be on the main thread anymore (assuming it was before the call). This is fine most of the time, especially if you don’t care about the threads that are handling the context before and after the call.

Some opinions differ from others on whether or not ConfigureAwait(false) is ever really a good idea, but it seems like, all else being equal, the safest option is ConfigureAwait(true).

That’s the default, so it’s not necessary to specify it unless you want to be more explicit about it, I suppose. This way technically has a performance implication, but it’s generally a negligible one.

dotnet c_sharp async