Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace Signaling_with_Event_Wait_Handles
- {
- internal class Program
- {
- private static EventWaitHandle handle = new ManualResetEvent(false);
- private static void Main()
- {
- handle.Set();
- new Thread(SayHello).Start("Holla");
- new Thread(SayHello).Start("hello");
- new Thread(SayHello).Start("hi");
- new Thread(SayHello).Start("hey");
- new Thread(SayHello).Start("ivandro");
- new Thread(SayHello).Start("ismael");
- new Thread(SayHello).Start("gomes jao");
- Thread.Sleep(2000);
- handle.Reset();
- new Thread(SayHello).Start("bonjour!");
- Thread.Sleep(4000);
- Thread.Sleep(4000);
- handle.Set();
- }
- private static void SayHello(object obj)
- {
- Console.WriteLine("Inside Sayhello data = " + obj);
- handle.WaitOne();
- Console.WriteLine(obj);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement