static void Main(string[] args) { ClockPublisher publisher = new ClockPublisher(); ClockSubscriber subscriber = new ClockSubscriber(); subscriber.Subscribe(publisher); publisher.Run(); }
public void OnSecondChanged(ClockPublisher publisher, Clock time) { SecondChanged(publisher, time); }
public void Subscribe(ClockPublisher publisher) { publisher.SecondChanged += new ClockPublisher.SecondChangedHandler(OnTimeChanged); }
private void OnTimeChanged(ClockPublisher publisher, Clock time) { Console.WriteLine($"The current time is {time.Hour}:{time.Minute}:{time.Second}"); }