Пример #1
0
        public void DoRun()//获取现在的时间,比较小时、分、秒
        {
            System.DateTime currentTime = new System.DateTime();

            ClockTimeArgs args = new ClockTimeArgs();

            int time = 0;

            while (time < 24 * 60 * 60)
            {
                time++;

                int hour   = DateTime.Now.Hour;
                int minute = DateTime.Now.Minute;
                int second = DateTime.Now.Second;

                System.Threading.Thread.Sleep(1000);



                if ((hour < H) || (minute < M) || (second < S))
                {
                    Run(this, args);
                }
                if (hour >= H && minute >= M && second >= S)
                {
                    Console.WriteLine("闹钟到了!!");
                    Console.WriteLine("/a");
                }
            }
        }
Пример #2
0
 static void ShowTime(object sender, ClockTimeArgs e)
 {
     Console.WriteLine("Clock is run . . .");
 }