【发布时间】:2014-08-08 15:08:25
【问题描述】:
我有一个带有计时器的小游戏,当新比赛开始时计时器必须重置,但实际上新计时器和旧计时器交替重叠。我不明白为什么。
当一个新游戏启动这个方法时,它被调用:
private void setGame()
{
game = new Game();
game.gameData.stopWatch = new StopWatch(timerLabel);
game.gameData.scoreLabel = scoreLabel;
}
public StopWatch(Label timerLabel)
{
this.timerLabel = timerLabel;
_timer = new Timer();
_timer.Interval = 1000;
_timer.Tick += new EventHandler(_timer_Tick);
}
然后_timer_Tick 被调用一次与实际匹配的startData 和另一次与旧匹配的startData。为什么?
【问题讨论】: