每10秒使用计时器中的方法 [英] method in timer every 10 seconds
本文介绍了每10秒使用计时器中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用wp7应用程序,我想创建一个计时器,其中每10秒在后台调用一个方法.我正在尝试搜索它,但找不到适合我的示例.
I am using a wp7 application, and i would like to make a timer in which every 10 seconds a method is called in the background. i am trying to google it but i cannot find any examples which are good for me.
any help please?
推荐答案
对于Windows Phone 7,您应该使用在System.Windows.Threading
名称空间中找到的DispatcherTimer
.然后您只需向其Tick EventHandler
添加一个方法
With Windows Phone 7 you should use theDispatcherTimer
found in theSystem.Windows.Threading
namespace. Then you just add a method to it''sTick EventHandler
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Tick += new EventHandler(Tick);
dt.Start();
void Tick(object sender, EventArgs e)
{
// Do work here.
}
希望对您有帮助
hope this helps
这篇关于每10秒使用计时器中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文