У меня есть таймер игры в покер Приложение Silverlight, которое теряет время (после работы в течение 1 часа 40 минут оно потеряло 3 минуты).
Я использую таймер DispatcherTimer в своем классе Турнира, и на каждом тике я вызываю событие, на которое подписывается пользовательский интерфейс для обновления экрана (с помощью текстового блока DataBound).Затем я проверяю, закончился ли блайнд или осталось 60 секунд и т. Д .:
private DispatcherTimer timerBlind;
if (timerBlind == null)
{
timerBlind = new DispatcherTimer();
timerBlind.Interval = TimeSpan.FromSeconds(1);
timerBlind.Tick += new EventHandler(Timer_Tick);
}
void Timer_Tick(object sender, EventArgs e)
{
//check if this would be the end of the blind or other key events
OnTimerTick(new EventArgs());
BlindSet.TotalTimeRunning = BlindSet.TotalTimeRunning.Add(TimeSpan.FromSeconds(1));
if (IsTimerBlindRunning)
{
BlindSet.TimeLeftInCurrentBlind = BlindSet.TimeLeftInCurrentBlind.Add(TimeSpan.FromSeconds(-1));
if (BlindSet.TimeLeftInCurrentBlind.TotalSeconds == 0)
{
//advance the level = blinds have gone up
blindset.EndOfBlindGoToNextLevel();
}
}
}
Итак, как мне сделать его более точным?Спасибо за любой совет ...