コード例 #1
0
        static void Main(string[] args)
        {
            // create a clock
            Timer timer = new Timer();

            // create some alarms
            iObserver alarm1 = new TextAlarm(10, "Wake up!");

            // attach the alarms to the clock
            timer.Attach(alarm1);

            // run the clock for thirty seconds
            timer.Run(30);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // create a clock
            Timer timer = new Timer();

            // create some alarms
            TextAlarm alarm1 = new TextAlarm("Wake up!");
            BeepAlarm alarm2 = new BeepAlarm();

            // attach the alarms to the clock
            //timer.Attach(alarm1);
            //timer.Attach(alarm2);

            // run the clock for thirty seconds
            timer.Run(3);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // create a clock
            Clock clock = new Clock();

            // create some alarms
            TextAlarm alarm1 = new TextAlarm("Wake up!");
            BeepAlarm alarm2 = new BeepAlarm();

            // attach the alarms to the clock
            clock.Attach(alarm1);
            clock.Attach(alarm2);

            // run the clock for thirty seconds
            clock.Run(30);
        }