Example #1
0
        //主函数
        public void Work()
        {
            while (time != this.alarmTime)//未到响铃时间时或者超过响铃时间时,时间增加
            {
                Console.WriteLine("time:" + time + " tick");
                System.Threading.Thread.Sleep(1000);
                time = time + 1;
            }
            ReachTimeEventArgs e = new ReachTimeEventArgs(this.time);

            ReachTime(this, e);//触发事件
        }
Example #2
0
        //按下任意键后响铃终止
        public void Press(object sender, ReachTimeEventArgs e)
        {
            Clock  w   = (Clock)sender;
            string str = Console.ReadLine();

            while (str == "\n")
            {
            }
            Console.WriteLine("power off");
            w.Time = (w.Time) + 1;
            //Console.WriteLine(w.Time);
            w.Work();
        }
Example #3
0
        //响铃
        public void Belling(object sender, ReachTimeEventArgs e)
        {
            Clock w = (Clock)sender;

            Console.WriteLine("time:" + w.Time + " didi ");
        }