Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 // 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);
 }
Exemplo n.º 3
0
 public Subscriber(Publisher pub)
 {
     pub.RaiseCustomEvent += HandleCustomEvent;
 }