17

在 c# 中开发 Windows 应用商店应用程序时找不到计时器。它的替代/新名称/使用方式是什么?

4

2 回答 2

19

DispatcherTimer是你要找的

var timer = new DispatcherTimer();
timer.Tick += DispatcherTimerEventHandler;
timer.Interval = new TimeSpan(0,0,0,1);
timer.Start();
于 2012-12-08T01:31:46.413 回答
16

不同的定时器满足不同的需求。大致...

DispatcherTimer - 当您希望在UI 线程上执行工作时。

ThreadPoolTimer - 当您希望在后台线程上执行工作时。

于 2013-09-17T21:27:22.370 回答