Beispiel #1
0
 public bool RemoveBroadcast(BroadcastToken broadcastToken)
 {
     if (broadcastToken == null)
     {
         throw new ArgumentNullException(nameof(broadcastToken));
     }
     if (Broadcasts.Contains(broadcastToken))
     {
         Broadcasts.Remove(broadcastToken);
         return(true);
     }
     return(false);
 }
Beispiel #2
0
 public bool RemoveBroadcast(BroadcastToken broadcastToken)
 {
     if (broadcastToken == null)
     {
         throw new ArgumentNullException(nameof(broadcastToken));
     }
     if (Broadcasts.Contains(broadcastToken))
     {
         Broadcasts.Remove(broadcastToken);
         return true;
     }
     return false;
 }
Beispiel #3
0
 public bool AddBroadcast(BroadcastToken broadcastToken)
 {
     if (broadcastToken == null)
     {
         throw new ArgumentNullException(nameof(broadcastToken));
     }
     if (!Broadcasts.Contains(broadcastToken))
     {
         broadcastToken.Event += Broadcast;
         Broadcasts.Add(broadcastToken);
         return(true);
     }
     return(false);
 }
Beispiel #4
0
 public bool AddBroadcast(BroadcastToken broadcastToken)
 {
     if (broadcastToken == null)
     {
         throw new ArgumentNullException(nameof(broadcastToken));
     }
     if (!Broadcasts.Contains(broadcastToken))
     {
         broadcastToken.Event += Broadcast;
         Broadcasts.Add(broadcastToken);
         return true;
     }
     return false;
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            var router    = new Router();
            var broadcast = new BroadcastToken("TimerBroadcast", null, null);

            router.AddBroadcast(new BroadcastToken("TimerBroadcast", null, null));
            var subscription = new SubscriptionToken(null, handler, broadcastType: typeof(BroadcastToken));

            router.Subscribe(subscription);

            Timer timer = new Timer();

            timer.Interval = 5000;
            timer.Elapsed += broadcast.Broadcast;
            timer.Start();

            new ManualResetEvent(false).WaitOne();
        }