public bool RemoveBroadcast(BroadcastToken broadcastToken) { if (broadcastToken == null) { throw new ArgumentNullException(nameof(broadcastToken)); } if (Broadcasts.Contains(broadcastToken)) { Broadcasts.Remove(broadcastToken); return(true); } return(false); }
public bool RemoveBroadcast(BroadcastToken broadcastToken) { if (broadcastToken == null) { throw new ArgumentNullException(nameof(broadcastToken)); } if (Broadcasts.Contains(broadcastToken)) { Broadcasts.Remove(broadcastToken); return true; } return false; }
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); }
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; }
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(); }