定时器的Windows Phone 8 [英] Timer for Windows Phone 8

查看:117
本文介绍了定时器的Windows Phone 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在1分钟左右的时间间隔来执行的功能。我怎样才能在Windows Phone的实现这一点8.搜索结果我不是在寻找的后台代理的。该应用程序将在前台运行。我有哪些选择?

I wish to execute a function at an interval of 1 or so minutes. How can I achieve this in Windows Phone 8.

I am not looking for background agents. The app will be running in the foreground. What are my options?

推荐答案

您可以使用DispatcherTimer类

you can use the DispatcherTimer Class

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

这篇关于定时器的Windows Phone 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆