static void Main(string[] args) { ClockPublisher clockPublisher = new ClockPublisher(); ClockSubScriber clockSubscriber = new ClockSubScriber(); clockSubscriber.Subscribe(clockPublisher); clockPublisher.Run(); }
public void Subcribe(ClockPublisher publisher) { publisher.SecondChange += new ClockPublisher.SecondChangeHandler(TimeHasChanged); }
private void TimeHasChanged(ClockPublisher clockPublisher, Clock time) { Console.WriteLine($"The current time is {time.Hour} : {time.Minute} : {time.Second}"); }
// Create method to fire Event public void OnSecondChange(ClockPublisher clockPublisher, Clock time) { SecondChange(clockPublisher, time); }