Ejemplo n.º 1
0
        public void timing()
        {
            string s = "";

            Console.WriteLine("please set time,for example 19:45:21");
            s = Console.ReadLine();
            while (DateTime.Now.ToLongTimeString().ToString() != s)
            {
            }
            ClockEventArgs args = new ClockEventArgs();

            Clocker(this, args);
        }
Ejemplo n.º 2
0
        public void setAlerm()
        {
            Console.WriteLine("请输入闹钟时间,格式为18:00:00");
            string s = "";

            s = Console.ReadLine();
            DateTime expTime = DateTime.Parse(s);
            TimeSpan a       = new TimeSpan(0, 0, 1);

            while (true)
            {
                System.Threading.Thread.Sleep(1000);
                if ((expTime - DateTime.Now) < a)
                {
                    Console.WriteLine(DateTime.Now - expTime);
                    ClockEventArgs args = new ClockEventArgs();
                    args.nowTime = expTime;
                    Alerm(this, args);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 static void ShowProgress(object sender, ClockEventArgs s)
 {
     Console.WriteLine("Alerm!! Time is " + s.nowTime + " Now!!!");
 }
Ejemplo n.º 4
0
 //回调函数
 static void showTiming(object sender, ClockEventArgs e)
 {
     Console.WriteLine("闹钟响了");
 }