示例#1
0
文件: Clock.cs 项目: jonwa/CSharp
        public Clock(DateTime wakeup, bool snooze = false, int numSnooze = 0, int snoozeInterval = 0)
        {
            _info = new AlarmInfo();
            _info.Time = DateTime.Now;

            _e = new AlarmEventArgs();
            _e.Time = wakeup;
            _e.Snooze = snooze;
            _e.NumSnooze = numSnooze;
            _e.SnoozeInterval = snoozeInterval;
        }
示例#2
0
文件: Program.cs 项目: jonwa/CSharp
        private static void AlarmHandler(ref Clock.AlarmInfo info, AlarmEventArgs e)
        {
            int count = 0;
            do
            {
                Thread.Sleep(200);
                Console.WriteLine("Ring...");

                count++;
            } while (count < 4);

            Console.WriteLine();
            Console.WriteLine("Next snooze is in {0} minutes\nWakeup time is set to {1}", e.SnoozeInterval, e.Time);
            Console.WriteLine();
        }
示例#3
0
文件: Program.cs 项目: jonwa/CSharp
 private static void TickHandler(ref Clock.AlarmInfo info, AlarmEventArgs e)
 {
     Console.WriteLine("Now {0}", info.Time);
 }
示例#4
0
文件: Clock.cs 项目: jonwa/CSharp
 protected virtual void OnAlarm(AlarmEventArgs e)
 {
     AlarmEventHandler handler = AlarmEvent;
     if (handler != null)
     {
         handler(ref _info, e);
     }
 }