public void run() { pub = new Publisher(); Subscriber sub = new Subscriber(pub); // Create a timer Timer myTimer = new System.Timers.Timer(); // Tell the timer what to do when it elapses myTimer.Elapsed += new ElapsedEventHandler(myEvent); // Set it to go off every five seconds myTimer.Interval = 5000; // And start it myTimer.Enabled = true; }
// Define what actions to take when the event is raised. void HandleCustomEvent(Object sender, Publisher.CustomEventArgs e) { Console.WriteLine("HEARD IT AT {0}", e.TimeReached); }
public Subscriber(Publisher pub) { pub.RaiseCustomEvent += HandleCustomEvent; }