这里的问题是调度程序计时器只激活一次。这在 UI 的文本框中显示为计时器 (1) 的循环时间。我希望它一直激活。
DispatcherTimer timer;
int timerRound=0;
public partial class AdventureMap : PhoneApplicationPage
{
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(30);
this.timer.Tick += new EventHandler(timer_Tick);
this.Loaded += new RoutedEventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
timerRound++;
textBox.Text = "Timer updates! round " + timerRound;
}