I run 3 tasks that each perform their role. I thought that adding an async Run program would wait until all tasks were completed, but it was wrong. The loop immediately goes to the string int x=2; . How to wait for tasks?
public async Task Run() { Task.Factory.StartNew(() => { // Задача 1 } Task.Factory.StartNew(() => { // Задача 2 } Task.Factory.StartNew(() => { // Задача 3 } } private async void button1_Click(object sender, EventArgs e) { await Run(); // он не ожидает завершения задача, а сразу переходит вниз int x = 2; }