public void ShowEventInfo() { foreach (Delegate handler in TestEvent.GetInvocationList()) { Console.WriteLine("EventHandler Method = {0}.{1}", handler.Method.DeclaringType, handler.Method.Name); } }
public void TestInit() { if (TestEvent != null) { foreach (var d in TestEvent.GetInvocationList()) { TestEvent -= (d as EventHandler <AsyncEventArgs>); } } }
public void ReverseInvocationList() { Delegate[] handlers = TestEvent.GetInvocationList(); if (handlers.Length > 0) { // remove the handlers first foreach (EventHandler handler in handlers) { TestEvent -= handler; } // reveres the order of the handlers Array.Reverse(handlers); // now, add the handlers back foreach (EventHandler handler in handlers) { TestEvent += handler; } } }
public Delegate[] GetInvocationList() { return(TestEvent != null?TestEvent.GetInvocationList() : new Delegate[0]); }