Пример #1
0
 public void ClearSomeEvent()
 {
     foreach (EventHandler e in SomeEvent.GetInvocationList())
     {
         SomeEvent -= e;
     }
 }
Пример #2
0
 public void ClearEventHandlers()
 {
     Delegate[] delegates = SomeEvent.GetInvocationList();
     foreach (Delegate delegate in delegates)
     {
         SomeEvent -= (EventHandler) delegate;
     }
 }
Пример #3
0
 void Elapsed(object sender, ElapsedEventArgs e)
 {
     if (SomeEvent != null)
     {
         Console.WriteLine("Hogs in memory: {0}",
                           SomeEvent.GetInvocationList().Count());
     }
 }
 // the event is private, and we can only subscribe
 // through this method
 public void Subscribe(Action callback)
 {
     // 'callback' already attached?
     if (SomeEvent != null && SomeEvent.GetInvocationList().Contains(action))
     {
         return;
     }
     SomeEvent += callback;
 }
Пример #5
0
    protected virtual void OnSomeEvent(MyEventArgs e)
    {
        var listeners = SomeEvent.GetInvocationList();

        foreach (var listener in listeners)
        {
            if (e.Handled)
            {
                break;
            }
            ((EventHandler <MyEventArgs>)listener).Invoke(this, e);
        }
    }
Пример #6
0
 private void OnSomeEvent()
 {
     if (SomeEvent != null)
     {
         var eventListeners = SomeEvent.GetInvocationList();
         Console.WriteLine("Raising Event");
         for (int index = 0; index < eventListeners.Count(); index++)
         {
             var methodToInvoke = (EventHandler)eventListeners[index];
             methodToInvoke.BeginInvoke(this, EventArgs.Empty, EndAsyncEvent, null);
         }
         Console.WriteLine("Done Raising Event");
     }
 }
Пример #7
0
 public Delegate[] GetSomeEventInvocationList()
 {
     return(SomeEvent.GetInvocationList());
 }