实施后DispatcherTimer
,我的涉及用户交互的应用程序不起作用。有关更多信息,我正在尝试使用跳跃运动开发应用程序。需要定时器与 UI 一起工作,以便用户做出一些手势并在定时器结束后停止,但现在跳跃运动在使用调度程序定时器后不再检测任何手势。请给点建议谢谢!
我的计时器代码:
public MainWindow()
{
dispatcherTimer = new DispatcherTimer();
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Tick += dispatcherTimer_Tick;
dispatcherTimer.Start();
}
void dispatcherTimer_Tick(object sender, EventArgs e)
{
if (time > 0)
{
if (time <= 10)
{
if (time % 2 == 0)
{
TBCountdown.Foreground = Brushes.Red;
}
else
{
TBCountdown.Foreground = Brushes.Red;
}
time--;
TBCountdown.Text = string.Format("00:0{0}:0{1}", time / 60, time % 60);
}
else
{
time--;
TBCountdown.Text = string.Format("00:0{0}:{1}", time / 60, time % 60);
}
}
else
{
dispatcherTimer.Stop();
MessageBox.Show("Completed");
}
}