I am just wondering in an app without a SynchronizationContext
(e.g. Console), how is async static Main(args)
implemented. Is the start of the main method before any await
a
Threadpool thread, where the CLR itself has a dedicated thread which queues
Main
call onto the threadpool and synchronously waits for it to finish?OR
Is it a dedicated starter thread, which gets compiled into a special state machine, to synchronously block the thread at each await. Or even maybe all
await
s get combined into one and themain
thread waits for this combined task to complete?
Main(args).GetAwaiter().GetResult();