WPF定时器如C#定时器 [英] WPF Timer Like C# Timer

查看:1004
本文介绍了WPF定时器如C#定时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里可以找到控制它类似于C#定时器控制在WPF?

Where can I find a control which is like the C# Timer Control in WPF?

推荐答案

通常WPF定时器是 DispatcherTimer ,这是不是一个控制,但在code使用。它基本上以同样的方式类似的WinForms定时器:

The usual WPF timer is the DispatcherTimer, which is not a control but used in code. It basically works the same way like the WinForms timer:

System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += dispatcherTimer_Tick;
dispatcherTimer.Interval = new TimeSpan(0,0,1);
dispatcherTimer.Start();


private void dispatcherTimer_Tick(object sender, EventArgs e)
{
  // code goes here
}

更多关于DispatcherTimer可以发现<一个href=\"http://msdn.microsoft.com/en-gb/library/system.windows.threading.dispatchertimer%28v=vs.90%29.aspx\">here

这篇关于WPF定时器如C#定时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆