您的位置:首页 > 其它

System.Timers.Timer的使用

2009-09-29 16:59 489 查看
System.Timers.Timer的使用
2008年11月04日 星期二 05:26 P.M.
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Timers;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

System.Timers.Timer aTimer = new System.Timers.Timer();

aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

// Set the Interval to 5 seconds.

aTimer.Interval = 5000;

aTimer.Enabled = true;

Console.WriteLine("Press \'q\' to quit the sample.");

while (Console.Read() != 'q') ;

}

private static void OnTimedEvent(object source, ElapsedEventArgs e)

{

Console.WriteLine("Hello World!");

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: