TimeSpan.FromSeconds
takes a double, and can represent values down to 100 nanoseconds, however this method inexplicably rounds the time to whole milliseconds.
Given that I've just spent half an hour to pinpoint this (documented!) behaviour, knowing why this might be the case would make it easier to put up with the wasted time.
Can anyone suggest why this seemingly counter-productive behaviour is implemented?
TimeSpan.FromSeconds(0.12345678).TotalSeconds
// 0.123
TimeSpan.FromTicks((long)(TimeSpan.TicksPerSecond * 0.12345678)).TotalSeconds
// 0.1234567
See Question&Answers more detail:os