using System;
using System.Timers;

namespace TimerExample
{
class Program
{

static void Main(string[] args)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Enabled = true;
timer.Interval = 600000; //执行间隔时间,单位为毫秒; 这里实际间隔为10分钟
timer.Start();
timer.Elapsed += new System.Timers.ElapsedEventHandler(test);

Console.ReadKey();
}

private static void test(object source, ElapsedEventArgs e)
{

Console.WriteLine("OK, test event is fired at: " + DateTime.Now.ToString());

}
}
}

 

http://www.cnblogs.com/wusir/p/3636149.html

文章標籤
全站熱搜
創作者介紹
創作者 amychang2014 的頭像
amychang2014

工作需要筆記

amychang2014 發表在 痞客邦 留言(0) 人氣(2,158)