When an async method is called from a lets say UI thread, if the runtime stumbles upon an await line, it will hand over the awaitable task to a worker thread and release the UI thread. Based on this my question is when an async method has multiple awaits and for ConfigureAwait
false or true scenarios, does the runtime switch threads every time it hits an await block? If so wouldn't it cause a lot of thread switching in methods with multiple awaits?
see the code below
static async Task MainAsync()
{
/* worker thread takes over */
await awaitable;
/* worker thread or the original thread
* (depending on configure await)
* hands execution over to another worker thread? */
await anotherawaitable;
}
is this the case?