public void Run() { for (; ;) { Thread.Sleep(200); DateTime dt = DateTime.Now; if (dt.Second != second) { TimeEventArgs ta = new TimeEventArgs(dt.Hour, dt.Minute, dt.Second); if (listOfHandlers != null) { listOfHandlers(this, ta); } } this.hour = dt.Hour; this.minute = dt.Minute; this.second = dt.Second; } }
//wvwnt handler to implement the publisher's delegate public void LogInfo(object clock, TimeEventArgs args) { Console.WriteLine("Logging the time infos ==> Time {0}::{1}::{2}", args.hour, args.minute, args.second); }
//event handler to implement publishers delegate public void ShowDisplayTime(object clock, TimeEventArgs args) { Console.WriteLine("The time is {0}::{1}::{2}", args.hour, args.minute, args.second); }