【问题标题】:Where is timer in a Windows store app?Windows 商店应用程序中的计时器在哪里?
【发布时间】:2012-12-08 00:01:45
【问题描述】:

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

【问题讨论】:

  • 您在寻找什么样的计时器? .NET 提供了三种类型的 Timer,每一种都有自己的特殊用途。
  • 现在我正在寻找 System.Windows.Forms.Timer 的替代品

标签: c# timer windows-store-apps


【解决方案1】:

DispatcherTimer 就是你要找的东西

var timer = new DispatcherTimer();
timer.Tick += DispatcherTimerEventHandler;
timer.Interval = new TimeSpan(0,0,0,1);
timer.Start();

【讨论】:

    【解决方案2】:

    不同的计时器满足不同的需求。大概……

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多