Ejemplo n.º 1
0
 void HandleChannelEvent(object sender, ChannelEventArgs e)
 {
     Console.WriteLine("User {0} sent {1} from {2}: {3}", e.UserName, e.EventName, e.ChannelName, e.Message);
 }
Ejemplo n.º 2
0
        protected virtual void RaiseChannelEvent(string channelName, string eventName, string userName, string message)
        {
            var e = new ChannelEventArgs(channelName, eventName, userName, message);
              // Make a temporary copy of the event to avoid possibility of
              // a race condition if the last subscriber unsubscribes
              // immediately after the null check and before the event is raised.
              EventHandler<ChannelEventArgs> handler = ChannelEvent;

              // Event will be null if there are no subscribers
              if (handler != null)
              {
            // Use the () operator to raise the event.
            handler(this, e);
              }
        }