Consider this example:
async Task Foo()
{
button.Text = "This is the UI context!";
await BarA();
button.Text = "This is still the UI context!";
await BarB();
button.Text = "Oh no!"; // exception (?)
}
async Task BarA()
{
await Calculations();
}
async Task BarB()
{
await Calculations().ConfigureAwait(false);
}
How do I know if calling await BarB()
changes the context without reading the body of the async Task BarB()
function? Do I really need to know exactly whether an async function calls ConfigureAwait(false)
at any point? Or maybe the example is wrong and there's no exception?