I’m wanting to set up delays of less than a millisecond in a project I’m working on. I can’t use Thread.Sleep() because that will sleep my thread for AT LEAST one millisecond.
I’ve seen techniques like this used before:
var ticks_per_micro = TimeSpan.TicksPerMillisecond * 1000; var ticks_to_wait = ticks_per_micro * microseconds_to_wait; var ticks_then = Utility.GetMachineTime().Ticks + ticks_to_wait; while( Utility.GetMachineTime().Ticks < ticks_then ) ; // done waiting...
… but it strikes me that that method is a bit brute-force. Is there something better? Could something be worked out with RLP?