C# 定时器(timer)使用范例

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

using System;
using System.Timers;
class TestTimer
{
    public static void Main()
    {
        Timer timer = new Timer();
        timer.Elapsed += new ElapsedEventHandler( DisplayTimeEvent );
        timer.Interval = 1000;
        timer.Start();
        timer.Enabled = true;
        while ( Console.Read() != 'q' )
        {
            //-------------
        }
    }
    public static void DisplayTimeEvent( object source, ElapsedEventArgs e )
    {
        Console.Write(\r{0}, DateTime.Now);
    }
}