by Ahmadreza Atighechi
30. March 2009 13:42
After long absence I'm back now. Recently I wanted to develop an application for windows mobile with .Net Compact framework. In this application I need to measure elapsed time in millisecond resolution. First of all like everyone I tried to use Millisecond property of DateTime.Now static class. But it won't work at all in .Net Compact framework even in version 3.5!
If you want to use a timer with millisecond resolution you have to use TickCount property of Environment class.
//Will be zero.
lblMillisecondVal.Text = DateTime.Now.Millisecond.ToString();
//Total milliseconds elapsed since the system started.
lblTickCountVal.Text = Environment.TickCount.ToString();
Here is an example of using TickCount Instead of Milliseconds