private void CheckTimer(TimerLibrary.Timer timer)
 {
     if (timer == null)
     {
         throw new ArgumentNullException($"{nameof(timer)} can't be null");
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            TimerLibrary.Timer timer            = new TimerLibrary.Timer();
            FirstSubscriber    firstSubscriber  = new FirstSubscriber();
            SecondSubscriber   secondSubscriber = new SecondSubscriber();

            firstSubscriber.Subscribe(timer);
            secondSubscriber.Subscribe(timer);

            timer.StartTimer(10, "test");

            secondSubscriber.Unsubscribe(timer);

            timer.StartTimer(5, "test1");

            System.Console.ReadLine();
        }
 public void Unsubscribe(TimerLibrary.Timer timer)
 {
     CheckTimer(timer);
     timer.TimerEnded -= ReceiveMessage;
 }