Timer, timespan and milliseconds

  • Thread starter Thread starter Andreas Ringdal
  • Start date Start date
A

Andreas Ringdal

I've made a simple stopwatch for .net cf 2 using DateTime dtStart
and Timespan tsInterval = DateTime.Now - dtStart

tsInterval.Milliseconds is always 0.
Does .net cf not support milliseconds.

I tried searching for this, and according to
http://msdn.microsoft.com/library/d...pref/html/frlrfsystemtimespanmemberstopic.asp
milliseconds is supported by .NET CF

Tested the code on my win 2003 box and the stopwatch works as planned,
but on my device (qtek 9100 / HTC Wizard), WM5. Milliseconds is always 0.

Is this a bug or a feature?

Andreas
 
CF supports it - most CE devices don't. Theres a good reason for it that I
won't go into, but the workaround is to use Environment.TickCount property.

-Chris
 
I made a working stopwatch using the Environment.TickCount property and
discovered that when my device is automatically turned off avter 3
minutes av inactivity, that counter also sleeps/slows down resuling in
my stopwatch claiming that there are 11 minutes 34 secons from 14:26:45
to 14:48:07

Going to check out the Stopwatch in the SDF from OpenNETCF as suggested
by Daniel Moth sometimes during the weekend.

Andreas
 
The tickcount is not really appropriate for counting milliseconds on a scale
over minutes like that with any accuracy. It's actually returning the
number of system ticks since boot. While that in theory is the number of
milliseconds, some drift can be expected, and how the implementation of the
OAL is handled can have a big impact on this - adding a sleep/wake cycle in
the middle of it could also add complication. Do you really need millisecod
resolution over such long periods of time, and even through a sleep/wake?

-Chris
 
No, most of the time I wont need milliseconds, but I'm working on
several smaller projects in order to get to know the compact frameworks
limitations and possibilities. Want to make an all purpose stopwatch
while I'm at it.

The main reason for writing the stopwatch application is to log my wifes
labour contractions and as a techhead I really can't do that using an
ordinary watch and writing down the time for each contraction.
Hope the application gets ready in time :)
 
Back
Top