Hi All,
I'm reading the Environment.TickCount property after a button click event to
create a basic stopwatch.
If I click the button as uniformly as possible, the resulting gap in
milliseconds seems to be far too even - ie. if I clicked the button 10 times
then there would probably be 2 or 3 intervals with exactly the same reading.
The chances of me being that accurate just by clicking a button are very low,
so either the environment.tickcount property is only accurate to 1/100th of a
second (in which case why is it trying to return a time to 1/1000th) OR my
button_Click event is only called with a set interval OR I am uniquely able
to time my finger movements to the nearest 1/1000th of a second.
If the first case is true - is there a more accurate timer available to me.
If the second case is true, can I increase the priority of button Click
events so they are more accurate?
If the third case is true does anyone have a phone number for Guinness Book
of Records?
I am coding in VB from Visual Studio 2005.
Many thanks in advance.
Michael Nemtsev - 01 Mar 2006 12:56 GMT
Environment.TickCount shows the milliseconds elapsed since the system started
It's a bit rough, because can't be less than 500 milliseconds.
Use DiteTime.Ticks for this reason
> Hi All,
>
[quoted text clipped - 17 lines]
> If the third case is true does anyone have a phone number for Guinness Book
> of Records?

Signature
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Michael D. Ober - 01 Mar 2006 14:15 GMT
Environment.TickCount is probably using the system API call GetTickCount().
If so, the interval quantum will be about 55 milliseconds. The primary
clock hardware on a PC only interrupts the processor 18.2 times per second,
or about every 55 milliseconds. For more accurate timing, you will need to
use the MultiMedia API timers. I don't know if they are exposed via the
framework.
Mike Ober.
> Hi All,
>
[quoted text clipped - 21 lines]
>
> Many thanks in advance.
Kamujin - 02 Mar 2006 13:55 GMT
Check out this code. http://www.windojitsu.com/code/hirestimer.cs.html
He is using the QueryPerformanceFrequency and QueryPerformanceCounter
API calls to get a more accurate samlpe.
Unless there is something new in the 2.0 framework, this is the
prefered method of obtaining a more accurate sample.
BTW, my GetTickCount() seems to have a resolution of 15ms.