AutoResetEvent taskFinished = new AutoResetEvent(false); // ThreadB code // perform some task taskFinished.Set(); // ThreadA code taskFinished.WaitOne();
AutoResetEvent userInputReceived = new AutoResetEvent(false); // wait for user input Console.WriteLine("Please enter some data:"); string userInput = Console.ReadLine(); // signal event when user input received userInputReceived.Set(); // wait for user input userInputReceived.WaitOne();Package library: The System.Threading.AutoResetEvent class is part of the .NET Framework class library, specifically the System.dll assembly.