public static void Main() { Console.WriteLine("---- Calling Main.TestIt ----"); TestIt(); Thread.Sleep(5000); Console.WriteLine("---- Calling AComponent.TestIt ----"); AComponent.TestIt(); }
public static void TestIt() { AComponent obj = new AComponent(); obj.myEvent += new EventHandler(TestHandler); obj.Work(); Thread.Sleep(1000); Console.WriteLine("Trying to unregister handler"); obj.myEvent -= new EventHandler(TestHandler); Console.WriteLine("handler unregistered"); }