Alternate to Thread.Sleep






1.02/5 (30 votes)
I coded this small stub to waste time as an alternate to
Thread.Sleep
:
private void WasteTime(TimeSpan unit) { DateTime now = DateTime.Now; DateTime then = DateTime.Now + unit; while (now < then) { now = DateTime.Now; } }Works quite preceisely.
private void WasteTime(TimeSpan unit) { DateTime then = DateTime.Now + unit; while (DateTime.Now < then) {;} }