In this video we answer the ever popular question “Which do I use, ConfigureAwait True or False?”.
The direct answer to this question is:
– If you are a writing code for the UI, use ConfigureAwait(true).
– If you are writing code in a library that will be shared, use ConfigureAwait(false)
If you want to know why, then keep watching until the end, because I teach you the difference between ConfigureAwait(true) and ConfigureAwait(false).
We start by understanding exactly how the await keyword in C# works. You learn about the continuation task and how to properly use ConfigureAwait to control which thread the continuation task runs on and why that’s important.
We talk about why the UI code relies on ConfigureAwait(true) and what happens if you set ConfigureAwait(false). Hint: you’ll get a threading exception.
We’ll also cover why you need to use ConfigureAwait(false) in all of your library code to help protect the consumers of your code from encountering deadlocks and other threading issues.