I have some delicate code that relies on Task.Delay being accurate enough such that it does not delay less then what is expected. If it delays more, that's fine. Basically, it boils down to this:
var now = DateTime.UtcNow;
var then = now + TimeSpan.FromMilliseconds(10);
await Task.Delay(10);
if (DateTime.UtcNow < then)
{
// Is it possible to get here?
}
I'm wondering if it's possible that the predicate within the if-statement can become true -- in that perhaps Task.Delay delayed slightly less, or if DateTime.Now is slightly inaccurate?
Assume that the clock will never be adjusted during execution.
Is this hardware dependent, OS dependent, or can it be guaranteed to always be false?