How can I set a timer to run from code? I can't find any control named timer.
What are the steps needed to do this?
本文介绍如何使用DispatcherTimer类在代码中设置定时器。通过创建DispatcherTimer实例并设置时间间隔及Tick事件处理委托,实现定时任务。
How can I set a timer to run from code? I can't find any control named timer.
What are the steps needed to do this?
You're looking for the DispatcherTimer class.
DispatcherTimer dt = new DispatcherTimer();
dt.Interval = TimeSpan.FromSeconds(10);
dt.Tick += delegate { ... };
dt.Start();
1万+
2616

被折叠的 条评论
为什么被折叠?