标签:c# timer 定时 定时器 dispatchertimer
先如下定义一个定时器:
public DispatcherTimer dispatcherTimer;
然后在某处创建这个对象实例:
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
设定超时回调函数:
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
设定间隔(下方例子是10秒钟):
dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
启动定时器:
dispatcherTimer.Start();
定义超时回调函数:
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
// do something here...
}
标签:c# timer 定时 定时器 dispatchertimer
原文地址:http://11225176.blog.51cto.com/11215176/1750486