I have a poker blind timer Silverlight app that is loosing time (after running for 1 hour 40 minutes it had lost 3 minutes).
I use a DispatcherTimer timer in my Tournament class and on every tick I raise an event which the UI subscribes to to update the screen (with a DataBound Textblock). I then do checks to see if the blind is over or if there is 60 seconds left etc:
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();
}
}
}
So, how do I make it more accurate? Thanks for any advice...