using System;
using System.Threading;
class MainClass
{
public static ManualResetEvent MyManualEvent = new ManualResetEvent(false);
public static AutoResetEvent MyAutoEvent = new AutoResetEvent(false);
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(DoBackgroundWorkManual));
MyManualEvent.WaitOne();
MyManualEvent.Reset();
ThreadPool.QueueUserWorkItem(new WaitCallback(DoBackgroundWorkAuto));
MyAutoEvent.WaitOne();
}
public static void DoBackgroundWorkManual(Object state)
{
Console.WriteLine("Thread 1");
MyManualEvent.Set();
}
public static void DoBackgroundWorkAuto(Object state)
{
Console.WriteLine("Thread 1");
MyAutoEvent.Set();
}
}
Thread 1
Thread 1