Use async Task instead of async void
private static async Task MainAsync(string[] args) { Console.WriteLine("Before start thread"); var task1 = Thread1(); var task2 = Thread2(); var taskList = new [] { task1, task2 }; Task.WaitAll(taskList); } var task1 = Thread1(); var task2 = Thread2();
var taskList = new [] { task1, task2 };
Task.WaitAll(taskList); }