예제 #1
0
        public static void Main()
        {
            // Create a new clock
            Clock theClock = new Clock();

            // Create the display and tell it to
            // subscribe to the clock just created
            DisplayClock dc = new DisplayClock();

            dc.Subscribe(theClock);

            // Create a Log object and tell it
            // to subscribe to the clock
            LogClock lc = new LogClock();

            lc.Subscribe(theClock);

            // Get the clock started
            theClock.Run();
        }
예제 #2
0
        public Form1()
        {
            InitializeComponent();
            Clock formClock = new Clock();



            // Create the display and tell it to
            // subscribe to the clock just created
            DisplayClock dc = new DisplayClock(textBox1);

            formClock.SecondChange += new Clock.SecondChangeHandler(dc.TimeHasChanged);


            // Create a Log object and tell it
            // to subscribe to the clock
            LogClock lc = new LogClock();

            formClock.SecondChange += new Clock.SecondChangeHandler(lc.WriteLogEntry);
            button1.Click          += formClock.Run;


            //
        }