コード例 #1
0
        public void MakeTheTick()
        {
            String    timeNow = DateTime.Now.ToString("hh:mm:ss");
            ClockTime args    = new ClockTime();

            Tick(this, args);
        }
コード例 #2
0
 void TimeGoes(object sender, ClockTime args)
 {
     while (true)
     {
         Console.WriteLine(DateTime.Now.ToLongTimeString());
         Thread.Sleep(1000);
     }
 }
コード例 #3
0
        public void MakeTheAlarm(int h, int m, int s)
        {
            ClockTime args = new ClockTime()
            {
                Hour   = h,
                Minute = m,
                Second = s
            };

            Alarm(this, args);
        }
コード例 #4
0
 void TimeIsUp(object sender, ClockTime args)
 {
     while (true)
     {
         String timeNow = DateTime.Now.ToString("hh:mm:ss");
         try
         {
             Console.WriteLine(timeNow);
             if (args.Hour == Convert.ToInt32(timeNow.Substring(0, 2)) && args.Minute == Convert.ToInt32(timeNow.Substring(3, 2)) &&
                 args.Second == Convert.ToInt32(timeNow.Substring(6, 2)))
             {
                 Console.WriteLine("RING...RING...RING...RING...RING...RING...RING...");
             }
         }
         catch
         {
             Console.WriteLine("error");
         }
         Thread.Sleep(1000);
     }
 }