[英]Windows Phone timed repeating method (like NSTimer in IOS)
Is there anytihng in WP7.5 like NSTimer in iOS where I can set a method to call once, or repeatedly at a set interval. 在WP7.5中是否存在类似于iOS中的NSTimer,我可以设置一个方法来调用一次,或者以设定的间隔重复调用。
Many Thanks, -Code 非常感谢,-Code
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = TimeSpan.FromMilliseconds(500);
dt.Tick +=new EventHandler(dt_Tick);
void dt_Tick(object sender, EventArgs e)
{
//code
}
and 和
dt.start() ;
dt.stop() ;
Depending on what you're trying to do, you'll want to use: 根据您要执行的操作,您需要使用:
Timer
, if you want to start a 'simple' background task : http://msdn.microsoft.com/en-us/library/system.threading.timer%28v=vs.95%29.aspx Timer
,如果你想开始一个'简单'的后台任务: http : //msdn.microsoft.com/en-us/library/system.threading.timer%28v=vs.95%29.aspx
DispatcherTimer
, if you want to modify the UI: http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer%28v=vs.95%29.aspx DispatcherTimer
,如果要修改UI: http : //msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer%28v=vs.95%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.