我想写一个应用程序来显示倒数计时器。当我按Home键退出应用程序或搜索按钮时,定时器将停止,直到我回到应用程序。这是我的代码:Windows Phone:如何让计时器在退出应用程序后继续运行?
public Page1()
{
InitializeComponent();
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Start();
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
//Till timer is greater than 0 show timer.
}
如何使用定时器的方式,它使甚至当我退出该应用程序计数(运行)?
你或许应该读作[这个问题的答案与(http://stackoverflow.com/questions/13514064/how-to-run-application-in-background-in-windows-phone),这似乎覆盖方式接近你要求的东西。 – Petesh