예제 #1
0
        static void Main(string[] args)
        {
            ClockPublisher  publisher  = new ClockPublisher();
            ClockSubscriber subscriber = new ClockSubscriber();

            subscriber.Subscribe(publisher);

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