コード例 #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);
 }
コード例 #2
0
ファイル: Router.cs プロジェクト: bkboggy/EventRouter
 public bool RemoveBroadcast(BroadcastToken broadcastToken)
 {
     if (broadcastToken == null)
     {
         throw new ArgumentNullException(nameof(broadcastToken));
     }
     if (Broadcasts.Contains(broadcastToken))
     {
         Broadcasts.Remove(broadcastToken);
         return true;
     }
     return false;
 }
コード例 #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);
 }
コード例 #4
0
ファイル: Router.cs プロジェクト: bkboggy/EventRouter
 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;
 }
コード例 #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();
        }