Esempio n. 1
0
        /// <summary>
        ///A method to run the subscribed DisplayClockObject method
        /// </summary>
        public static void run()
        {
            ClockObject clk = new ClockObject();

            new DisplayClockObject().subscribe(clk);
            //DisplayClockObject dco = new DisplayClockObject(); dco.subscribe(clk); //also permissible
            clk.run();
            Console.ReadKey();
        }
 public void timeChange(ClockObject clk, EventArgs t)
 {
     Console.WriteLine("The new time values are (month), (day) and (second): {0}:{1}:{2}", clk.Month, clk.Day, clk.Second);
 }
 public void subscribe(ClockObject clk)
 {
     clk.secondChanged += timeChange; //made static to enable referencing
     //theClock.secondChanged += new Clock.SecondChangedHandler(timeHasChanged); This is the same
 }