DateTime.now truncated to seconds?

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



    Giving me the following output:


    Code
    1. 7/29/2008 8:50:17 AM, elapsed: 0 ms.
    2. 7/29/2008 8:50:18 AM, elapsed: 1000 ms.
    3. 7/29/2008 8:50:18 AM, elapsed: 1000 ms.
    4. 7/29/2008 8:50:19 AM, elapsed: 2000 ms.
    5. 7/29/2008 8:50:19 AM, elapsed: 2000 ms.
    6. 7/29/2008 8:50:20 AM, elapsed: 3000 ms.
    7. 7/29/2008 8:50:20 AM, elapsed: 3000 ms.
    8. 7/29/2008 8:50:21 AM, elapsed: 4000 ms.
    9. 7/29/2008 8:50:21 AM, elapsed: 4000 ms.
    10. 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.

  • From MSDN:

    Quote

    Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note:


    In Windows CE, time is specific only to the second. You can get a more precise time span measurement, for example, in milliseconds, by using the TickCount property.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Quote from "CPE"

    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.


    From the .NET documentation to DateTime.Now:


    Quote


    The resolution of this property depends on the system timer.


    Windows NT 3.5 and later: 10 milliseconds
    Windows 98: 55 milliseconds


    Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: In Windows CE, time is specific only to the second. You can get a more precise time span measurement, for example, in milliseconds, by using the TickCount property.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.