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

c#
2015-05-02 0 413
C# 定时器(timer)使用范例
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);
    }
}

遇见资源网 c# C# 定时器(timer)使用范例 http://www.ox520.com/12444.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务