Yes, thanks Arne. I agree with your interpretation. I've tested
Environment.TickCount and it works well. Sure, there are limitations, but
its fine for what I need!
Thanks,
Alain
"Arne Vajhøj" <(E-Mail Removed)> wrote in message
news:4e0de93e$0$309$(E-Mail Removed)...
> On 7/1/2011 10:29 AM, Alain Dekker wrote:
>> I've written this code:
>>
>> long lStart = DateTime.Now.Ticks;
>> ...
>> DoLongComplexTask();
>> ...
>> decimal dElapsed = (((decimal)DateTime.Now.Ticks - (decimal)lStart) /
>> 10000000.0m);
>> lbDiagnostic.Text = ("Time taken: " + dElapsed.ToString("0.000") + "s");
>>
>> But all I ever get is one of these two:
>> "Time taken: 5.000s" or "Time taken: 6.000s"
>>
>> no matter how many times I try. This is weird. Why nothing after the
>> seconds? I should have varying number of milliseconds, but it seems to be
>> rounded. Is this a coding bug or is there something like the
>> GetTickCount()
>> I used to use in Delphi/C++ that I can use that is more accurate than
>> DateTime.Now.Ticks (which I note that documentation claims is accuracte
>> to
>> 100ns - not in my experience!).
>>
>> I'm writing the application in VS 2005, targetting the CF .NET 2.0 on
>> Windows CE if thats relevant.
>
> http://community.opennetcf.com/artic...indows-ce.aspx
>
> confirms that DateTime Now Ticks has a problem on Windows CE with
> milliseconds.
>
> If I read it correct then simply using Environment.TickCount may be good
> enough for your type of measuring.
>
> Arne
>