Possible Duplicate:
C# DateTime.Now precision
There are a few questions on SO regarding high-resolution timing in .NET where it is stated (as in the MSDN documentation) that the DateTime.Ticks has a resulution of 100 nano-seconds.
But this seem not to be the case at all in real-life. If I run the code below, I would expect it to generate lines, where the Tick value varies for each line, where a lot of lines are with the the same Milisecond value. But it doesn't - the ticks value stays the same until next shift in milisecond value, adding nothing to the resolution of the time-stamp.
private static List<string> GetTimeLine(long iterations)
{
List<string> liste = new List<string>();
for (long i = 0; i <= iterations; i++)
{
liste.Add(DateTime.Now.Millisecond.ToString() + " - " + DateTime.Now.Ticks.ToString());
}
return liste;
}
static void Main(string[] args)
{
Console.WriteLine("Generating timeline");
guids = GetTimeLine(10000);
File.WriteAllLines(@"C:\Test\GUIDS.TXT", guids);
Console.WriteLine("File written - Press ENTER");
Console.ReadLine();
}
Example of result output:
...
867 - 634940160118679615867 - 634940160118679615
867 - 634940160118679615
867 - 634940160118679615
867 - 634940160118679615
868 - 634940160118689616
868 - 634940160118689616
868 - 634940160118689616
...
So what is the method for getting more than miliseconds resolution in .NET?