Ejemplo n.º 1
0
 static void CheckClock(object sender, ClockEventArgs e) //比较时间
 {
     if (e.SetHour == e.CurrentHour && e.SetMinute == e.CurrentMinute)
     {
         e.TimeCheck = true;
         Console.WriteLine("闹钟响了!!!");
     }
 }
Ejemplo n.º 2
0
        public void Check(int Sethour, int Setminute)
        {
            ClockEventArgs args = new ClockEventArgs();

            args.TimeCheck = false;
            args.SetHour   = Sethour;
            args.SetMinute = Setminute;
            while (1 != 0)
            {
                args.CurrentHour   = Convert.ToInt32(DateTime.Now.Hour.ToString());
                args.CurrentMinute = Convert.ToInt32(DateTime.Now.Minute.ToString());
                WhetherClockRing(this, args);
                if (args.TimeCheck == true)
                {
                    break;
                }
                System.Threading.Thread.Sleep(1000);
            }
        }