c# – Windows Phone 8的计时器

我希望以1分钟左右的间隔执行一个函数.我怎样才能在Windows Phone 8中实现这一点.我不是在寻找background agents.该应用程序将在前台运行.我有什么选择?
您可以使用DispatcherTimer类

private DispatcherTimer dispatcherTimer;
    // Constructor
    public MainPage()
    {

        InitializeComponent();
        dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
        dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
        dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
        dispatcherTimer.Start();

    }

  private void dispatcherTimer_Tick(object sender, EventArgs e)
  {
    //do whatever you want to do here
  }

参考:(http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(v=vs.110).aspx)

https://stackoverflow.com/questions/22012056/timer-for-windows-phone-8

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:c# – Windows Phone 8的计时器