You can break this apart into several parts:
async () => { await SomeClass.Initiate(new Configuration()); }
Is a lambda expression that defines an async
method that just awaits another method. This lambda is then passed to Task.Run
:
Task.Run(async () => { await SomeClass.Initiate(new Configuration()); })
Task.Run
executes its code on a thread pool thread. So, that async
lambda will be run on a thread pool thread. Task.Run
returns a Task
which represents the execution of the async
lambda. After calling Task.Run
, the code calls Task.Wait
:
Task.Run(async () => { await SomeClass.Initiate(new Configuration()); }).Wait();
This will block the main console app until the async lambda is completely finished.
If you want to see how it's broken out further, the following is roughly equivalent:
static async Task AnonymousMethodAsync()
{
await SomeClass.Initiate(new Configuration());
}
static void Main(string[] args)
{
var task = Task.Run(() => AnonymousMethodAsync());
task.Wait();
while (true) ;
}