Hello everybody,
porting an application originally developed for a different target device, I noticed that a program ran terribly slow on the PicoMOD3. However, the problem turned out to be, that when using C#'s DateTime.Now, you only get a one second precision on the PicoMOD3!
Running my software on the previous system, I get milliseconds precision from this property, as supposed.
The other system is running Windows CE 5.0 with the Compact Framework 2.0
To reproduce this issue, I used this C# console application:
- using System;
- using System.Threading;
- using System.Diagnostics;
- namespace ConsoleTime
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime starttime = DateTime.Now;
- for (int i = 0; i < 10; i++)
- {
- TimeSpan elapsed = DateTime.Now - starttime;
- Debug.WriteLine(DateTime.Now + ", elapsed: " + elapsed.TotalMilliseconds + " ms.");
- Thread.Sleep(444);
- }
- }
- }
- }
Giving me the following output:
- 7/29/2008 8:50:17 AM, elapsed: 0 ms.
- 7/29/2008 8:50:18 AM, elapsed: 1000 ms.
- 7/29/2008 8:50:18 AM, elapsed: 1000 ms.
- 7/29/2008 8:50:19 AM, elapsed: 2000 ms.
- 7/29/2008 8:50:19 AM, elapsed: 2000 ms.
- 7/29/2008 8:50:20 AM, elapsed: 3000 ms.
- 7/29/2008 8:50:20 AM, elapsed: 3000 ms.
- 7/29/2008 8:50:21 AM, elapsed: 4000 ms.
- 7/29/2008 8:50:21 AM, elapsed: 4000 ms.
- 7/29/2008 8:50:22 AM, elapsed: 5000 ms.
How does this happen? Could it be Windows CE 6.0 or maybe hardware related?
Has anyone experienced the same problem?
Yes, it would be possible for me to use Environment.TickCount for the current project.
But I would also like to be able to use DateTime.Now as it is supposed to be.
Best regards, CPE.