using System;
using System.Threading.Tasks;
using System.Threading;
public class Program
{
public static void Main()
AutoResetEvent waitA = new AutoResetEvent(false);
AutoResetEvent waitB = new AutoResetEvent(false);
// Start tasks
Task task_1 = Task.Run(() =>
Console.WriteLine("1");
waitA.Set();
waitB.WaitOne();
Console.WriteLine("3");
});
Task task_2 = Task.Run(() =>
waitA.WaitOne();
Console.WriteLine("2");
waitB.Set();
task_2.Wait();
}