C#中定时器问题!!!我想设计一个定时器,精确到天,时分秒不考虑,用户通过dateTimePicker设定提醒日期,比如:现在是时间是2010-8-26
用户选择的提醒日期是2010-8-30这一天,等到系统时间到达这一天时,然后弹出消息窗体!
请问代码怎么写?请尽量详细点,我是初学的,谢谢!我知道定时秒的,代码如下:
private void help_Load(object sender, EventArgs e)
        { 
            System.Timers.Timer aTimer = new System.Timers.Timer(); 
            aTimer.Elapsed += new ElapsedEventHandler(theout); 
            
            aTimer.Interval =1000;//设置初始时间间隔为1秒!!!
            
            aTimer.AutoReset = true;            
            aTimer.Enabled = true;
        }  public void theout(object source, System.Timers.ElapsedEventArgs e)
        {
               ArrayList AutoTask = new ArrayList();
                  AutoTask.Add("8:30:00");
                  AutoTask.Add("9:30:00");
                  AutoTask.Add("10:30:00");
                  AutoTask.Add("11:30:00");
              for (int k = 0; k < 4; k++)
               {
                  if (DateTime.Now.ToLongTimeString().Equals(AutoTask[k]))
                   {
                       MessageBox.Show("现在时间是" + AutoTask[k]);
                   }
               }
        }      这样定时秒钟能成功,但我现在想以天数为单位,定时到某一天之后弹出消息窗体,代码怎么写?

解决方案 »

  1.   


    if(DateTime.now.ToString().Subsring(0,...)==你想要的时间(精确到天))
    MessageBox.Show(.....);
      

  2.   


    1楼是说这样吗?
    aTimer.Interval =1000*24*60*60;//设置初始时间间隔为1天!!!
      

  3.   

    不是,IntervaL等于多少不重要,只要不是太大就好,你在时间里面加个验证就行了吧
      

  4.   


    3楼,你还,我根据你的提示,在里面的代码如下,
    if (DateTime.Now.ToString().Substring(0, Arry[j].Length) == Arry[j])我是把“我想要的时间”放在string 数组里的,即Arry数组里,然后用的。
    可出不来效果啊!
    是什么情况?能否剖析下?
      

  5.   

    确定你设置的时间格式和DateTime.Now.ToString().Substring(0, Arry[j].Length)的格式一致?
      

  6.   

    将设置的日期保存在配置文件中,设置程序开机启动,启动后检查当前日子是否为设置的日期,是则弹出提示窗体,不是则自动关闭,over