class Program
    {
        private static System.Timers.Timer aTimer;
        static void Main(string[] args)
        {
            //int a, b;
            //ThreadPool.GetMaxThreads(out a, out b);
            //Console.WriteLine("线程池默认最大工作线程数:" + a.ToString() + "     默认最大异步 I/O 线程数:" + b.ToString());
            aTimer = new System.Timers.Timer(100);
            aTimer.AutoReset = true;
            aTimer.Enabled = true;
            Console.WriteLine("Press the Enter key to exit the program.");
            Console.ReadLine();
        }
        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            Console.WriteLine("Hello World!");
        }
    }

解决方案 »

  1.   

    msdn有示例,你这里并没有分配给定时器要做的事情
      

  2.   

    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.timer1.Interval = 1000;
                this.timer1.Enabled = true;///是否正在运行;
                this.label1.Text = DateTime.Now.ToString();
            }
              private void timer1_Tick(object sender, EventArgs e)
            {
                this.label1.Text = DateTime.Now.ToString();
            }
        }
    }
      

  3.   

    绑定定时器的Elapsed事件,另外ElapsedEventArgs 前要加上命名空间System.Timersclass Program
        {
            private static System.Timers.Timer aTimer;        static void Main(string[] args)
            {
                aTimer = new System.Timers.Timer(100);
                aTimer.AutoReset = true;
                aTimer.Enabled = true;
                aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);//绑定定时器事件
                Console.WriteLine("Press the Enter key to exit the program.");
                Console.ReadLine();
            }
            private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
            {
                Console.WriteLine("Hello World!");
            }
        }