This code won't work the way you think it does:
DateTime _starttime = DateTime.UtcNow;
Stopwatch _stopwatch = Stopwatch.StartNew();
At best, your accuracy will be 10-15 ms.
The reason is that UtcNow is only updated once per thread quantum. On Windows on multicore machines, the thread quantum is 15 ms; single core machines every 10 ms.
Stopwatch is very high accuracy and very high precision, so it is possible to do better. I'll illustrate by way of example.
If you have a real stopwatch that you can somehow use and get 1 ms precision and accuracy, can you take an alarm clock that only shows hours and minutes and do any better?
You can. You can measure the passage of time very accurately using the stopwatch. And you can watch the alarm clock to see when it ticks over from 11:14 am to 11:15 am.
For instance, if you observe the following set of events:
- Read stopwatch: 12000 ms
- Read clock: 11:14 am
- Read clock: 11:15 am
- Read stopwatch: 12002 ms
Then you know in the middle somewhere in there, the time was exactly 11:15:00.0000... and you know that it occurred within a span of time that was only 2 milliseconds, because your stopwatch told you so.
So now you know that stopwatch value 12001 +/- 1 ms == 11:15:00.000000
You can apply this same concept to DateTime.UtcNow() and StopWatch.
If you read the stopwatch and utcnow in a loop, and you see the UtcNow tick over from 11:14:31.030 to 11:14:31.045, then you know that the time was exactly 31.04500000 somewhere in there - and your stopwatch will tell you how much physical time actually passed, and thus you know how much error you have.