How to get precise DateTime in C#
c#, datetime
Solution
You can use `Stopwatch` for more precise measurements of time. You can then have each log entry record the time from the start of the first operation. If it's important, you can record the `DateTime` of the first operation and therefore calculate the times of the rest, but it sounds like just having the ticks/nanoseconds since the start of the first operation is good enough for your purposes.
Problem
I know that `DateTime.UtcNow` does not have a relatively high degree of precision (10-15 ms resolution). This is a problem for me because in my log files, I want better resolution for the purposes of resolving race conditions. The question is: how can I get the current date/time with a better precision than what `DateTime.UtcNow` offers? The only solution which I've seen up till now has been this: https://stackoverflow.com/a/15008836/270348. Is that a suitable way to solve the problem?