Пример #1
0
 private static void SyncDispatchEventItem(EventThreadItem <T> item)
 {
     if (item.Listener != null)
     {
         object data = Thread.GetData(Thread.GetNamedDataSlot("EventSlotName"));
         Thread.SetData(Thread.GetNamedDataSlot("EventSlotName"), item);
         item.Listener(item.Sender, item.EventArgs);
         Thread.SetData(Thread.GetNamedDataSlot("EventSlotName"), data);
     }
 }
Пример #2
0
 private void DispatchToListeners(object sender, T e, IEnumerable <EventHandler <T> > listeners, DispatchEventItemDelegate <T> dispatchEventItemDelegate)
 {
     foreach (EventHandler <T> handler in listeners)
     {
         EventThreadItem <T> item = new EventThreadItem <T> {
             Sender    = sender,
             EventArgs = e,
             Listener  = handler
         };
         try
         {
             dispatchEventItemDelegate(item);
         }
         catch (Exception exception)
         {
             FrameworkEventArgs args = new FrameworkEventArgs(FrameworkEventType.Error, this, exception);
             this._owner.DispatchFrameworkEvent(this, args);
         }
     }
 }