如果能,怎样创建?

解决方案 »

  1.   

    public class Timer2
     {
     
         public static void Main()
         {
           // Create a new Timer with Interval set to 10 seconds.
           System.Timers.Timer aTimer = new System.Timers.Timer(10000);
           aTimer.Elapsed+=new ElapsedEventHandler(OnTimedEvent);
           // Only raise the event the first time Interval elapses.
           aTimer.AutoReset = false;
           aTimer.Enabled = true;
     
           Console.WriteLine("Press \'q\' to quit the sample.");
           while(Console.Read()!='q');
         }
     
         // Specify what you want to happen when the event is raised.
         private static void OnTimedEvent(object source, ElapsedEventArgs e) 
         {
           Console.WriteLine("Hello World!");
         }
     }
      

  2.   

    lnjzxx (申伯君) 你这两天做什么?这么多问题?
      

  3.   

    using System;
    using System.Timers;class test
    {
         public static void Main()
         {
           Timer aTimer = new Timer(10000);
           aTimer.Elapsed+=new ElapsedEventHandler(OnTimedEvent);
       aTimer.Start();
         }
     
         private static void OnTimedEvent(object source, ElapsedEventArgs e) 
         {
    Console.WriteLine( DateTime.Now.Millisecond );
         }
    }
      

  4.   

    这和控制台什么关系,不管是控制台还是Winform或Webform还是WebService......这个都一样的.对于调试不过的程序,贴错误提示比贴代码管用.
      

  5.   

    aTimer.Start();
    ===============>aTimer.AutoReset = false;
    aTimer.Enabled = true;