【发布时间】:2014-01-12 09:03:53
【问题描述】:
我在 Windows Phone 7.1 的应用程序中有一个计时器,使用
实现DispatcherTimer _timer;
初始化为
Sample._timer = new DispatcherTimer();
Sample._timer.Interval = new TimeSpan(0, 0, 1);
Sample._timer.Tick += new EventHandler(Timer_Tick);
Sample._timer.Start();
private void Timer_Tick(object sender, EventArgs e)
{
double newValue = Sample.Value + 1.686;
if (newValue >= 100)
newValue = 0;
Sample.Value = newValue;
txtDigitalClock.Text = GetTime();
}
public string GetTime()
{
time += TimeSpan.FromSeconds(1);
return string.Format("{0:D2}:{1:D2}:{2:D2}", time.Hours, time.Minutes, time.Seconds);
}
这在正常情况下工作正常
这是我的问题
1) 手机处于锁定状态(屏幕锁定)时,定时器不运行
2) 应用程序在后台运行时定时器未运行(当您在 windows phone 中按下开始按钮时,应用程序进入后台)。
任何帮助将不胜感激..
【问题讨论】:
标签: c# windows-phone-8 timer windows-phone-7.1