Timer, timespan and milliseconds

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
 
G

Guest

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
 
A

andemann

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
 
G

Guest

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
 
A

Andreas Ringdal

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top