Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ClockPublisher  publisher  = new ClockPublisher();
            ClockSubscriber subscriber = new ClockSubscriber();

            subscriber.Subscribe(publisher);

            publisher.Run();
        }
Exemplo n.º 2
0
 public void OnSecondChanged(ClockPublisher publisher, Clock time)
 {
     SecondChanged(publisher, time);
 }
Exemplo n.º 3
0
 public void Subscribe(ClockPublisher publisher)
 {
     publisher.SecondChanged += new ClockPublisher.SecondChangedHandler(OnTimeChanged);
 }
Exemplo n.º 4
0
 private void OnTimeChanged(ClockPublisher publisher, Clock time)
 {
     Console.WriteLine($"The current time is {time.Hour}:{time.Minute}:{time.Second}");
 }