I'm trying to understand async await behavior and in particular how it affects the main thread, so my question is related to below code:
static async Task main(string[] args)
{
await LongAction();
}
static Task LongAction() => Task.Delay(10000);
what will happen with the main thread when LongAction
is being executed. As I understand, if the the caller thread is not the main (let's call it thread2), during the time when awaitable operation is in play, this thread (thread2) will be returned to the ThreadPool (with default task scheduler). But can it happen with the main thread (it doesn't looks so, since initially it wasn't taken from TP)? What if the main thread is UI thread with thread context?