Created
February 6, 2022 20:42
-
-
Save hkucuk/6553b38ef0466c247131b9e6c1fde6b1 to your computer and use it in GitHub Desktop.
Simple AutoResetEvent Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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