Skip to content

Instantly share code, notes, and snippets.

@hkucuk
Created February 6, 2022 20:42
Show Gist options
  • Save hkucuk/6553b38ef0466c247131b9e6c1fde6b1 to your computer and use it in GitHub Desktop.
Save hkucuk/6553b38ef0466c247131b9e6c1fde6b1 to your computer and use it in GitHub Desktop.
Simple AutoResetEvent Sample
class Program
{
static var are = new AutoResetEvent (false);
static void Main()
{
var t1 = new Thread (Task);
t1.Start();
Thread.Sleep (3000);
are.Set(); //send a signal
Console.WriteLine ("Main thread completed");
Console.Read();
}
static void Task()
{
Console.WriteLine ("Waiting...");
are.WaitOne(); // Wait a signal
Console.WriteLine ("Signal recived");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment