c# - Windows Phone 8 的计时器

标签 c# windows-phone-8 timer

我希望每隔 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)

关于c# - Windows Phone 8 的计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22012056/

相关文章:

javascript - 使用 JQuery Ajax 自动登录?

c# - 以 C# 形式将文本框中的信息显示到列表框中

C# 创建查找下一个函数

xaml - 在 ItemTemplate 上设置属性

c# - 何时以及如何在 Windows Phone wp8 中的 ViewModel 中调用异步方法

java - 使用 StringBuilder 将多行 Printwriter 转换为 CSV 文件

java - 创建基于 GUI 的计时器(或秒表)

c# - Entity Framework 查询思路(group by)

c# - 什么是执行框架?

c# - 如何在 Windows Phone 8 中解析 Json 数组内的图像?