niketas

niketas

  • NA
  • 1
  • 0

Timer and DateTime — clock goes wrong

Apr 7 2008 6:11 PM
Greetings.
First of all, I'm very sorry for my English.
Trying to create my own virtual clock with a function of time-accelerating. I want clock hands to rotate smoothly, so to accelerate clock speed I managed to go on with timer this way: I set up a timer with an interval of 1 millisecond, and when timer ticks, this procedure helds:

private void timer1_Tick(object sender, System.EventArgs e)
        {
                s  = (s + (double)hScrollBar1.Value / 100) % 60;
                //hScrollBar1.Value is a coefficient of accelerating
        }

So each 1 ms the s variable, responsible for seconds hand, increases by 0.01.

I have 2 questions:
1. When things go on like this, why there are 100 ms in a second instead of usual 1000?
2. Important: why clock is late approx. by 1.6 times to a usual DateTime clock when I use timer and timer_Tick inreasing of s (h, m, ms) variable? E.g., in “my clock's world” passes only 40 seconds, while in real world 64 has gone.

Appreciate your input very much! Can provide source project at any time, please, explain and/or help.

Answers (1)