Thursday, September 6, 2007

Millisecond component on .NET Compact Framework

One of the differences between full .NET Framework and .NET Compact Framework relates to the Time Intervals. The value returned from System.DateTime.Now is specific only to seconds, not milliseconds. Thus, the milliseconds component of the DateTime, usually expressed between 0 and 999 (in the full framework) will always be 0 on a compact framework platform.

Recommendation

Microsoft recommends the use of the TickCount property available in the Environment class in order to get a more precise time span measurement. This property returns the amount of time in milliseconds that has passed since the last time the computer was started.

http://msdn2.microsoft.com/en-us/library/system.environment.tickcount(vs.80).aspx

Hope it helps.

2 comments:

Anonymous said...

Excellent! Great info. Thanks
Carlos Perez (MVP devices app. development)

Anonymous said...

You really saved my life, I've been trying for almost half a day to find a workaround for the "millisecond" function...thanks a ton :-)

Venkatesh
Mobile Game Developer