我很菜,请解释详细点,注明要引用那些命名空间,这个要写在哪个地方(程序入口里还是外面哪里)我找的这个行吗?我把它写在程序入口里了using System.Timers;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;                System.Timers.Timer aTimer = new System.Timers.Timer(600000);
                aTimer.AutoReset = true;
                aTimer.Enabled = true;
                aTimer.Start();

解决方案 »

  1.   

    需要挂个执行事件,要不timer啥也不干了,写在入口没问题
    System.Timers.Timer t =   
    new System.Timers.Timer(10000);  
    //实例化Timer类,设置间隔时间为10000毫秒;   
    t.Elapsed +=   
    new System.Timers.ElapsedEventHandler(theout);  
    //到达时间的时候执行事件;   
    t.AutoReset = true;  
    //设置是执行一次(false)还是一直执行(true);   
    t.Enabled = true;  
    //是否执行System.Timers.Timer.Elapsed事件;   
     
    public void theout(  
    object source,   
    System.Timers.ElapsedEventArgs e)   
     {   
        MessageBox.Show("OK!");   
     }  
      

  2.   

    public void theout(   
    object source,   
    System.Timers.ElapsedEventArgs e)   
     {   
      MessageBox.Show("OK!");   
     } 
    ----这个的作用是什么?怎么看着和上段像没关联
    还有都写在入口里会出错,把上段写入口里,下段放入口外?
      

  3.   

    private void Form1_Load(object sender, EventArgs e)
            {
                Timer timer1 = new Timer();
                timer1.Interval = 3000;
                timer1.Enabled = true;
                timer1.Tick += new EventHandler(timer1_Tick);
            }        void timer1_Tick(object sender, EventArgs e)
            {
                // 这里处理定时需要执行的内容
            }
    还有windows 任务 
      

  4.   

    好吧好吧,完全不懂,和main函数怎么关联?直接举例了,每5秒钟输出一次"OK!"怎么写?using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Timers;
    using System.IO;
    using System.Diagnostics;
    using System.Threading;
    using System.Runtime.InteropServices;namespace _0fenzhong
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Timers.Timer t = new System.Timers.Timer(5000);        //实例化Timer类,设置间隔时间为?毫秒;   
                t.Elapsed += new System.Timers.ElapsedEventHandler(theout);   //到达时间的时候执行事件;   
                t.AutoReset = true;                                           //设置是执行一次(false)还是一直执行(true);   
                t.Enabled = true;                                             //是否执行System.Timers.Timer.Elapsed事件;   
            }
                public void theout(object source,System.Timers.ElapsedEventArgs e)   
                {   
                    Console.WriteLine("OK!");   
                } 
        }
    }