I need a solution to perform arbitrary pause. The delay accuracy is irrelevant. What is the practical difference in such scenario between WaitHandle.WaitOne Method (TimeSpan) and Thread.Sleep Method. Are there any better solutions?
If your spec says something like 'Always wait at least two seconds before continuing', use Sleep().
If your spec says something like 'Wait for up to two seconds for a signal from another thread and return an error if timed out' use an event object.
It's basically that simple.
There are essentially no 'performance differences' re. timing accuracy since both calls use the same mechanism for timeouts.
'Better' solutions - what is 'better'? Better in what respect?
1.Thread.Sleep(timeout) causes an unconditional wait before execution is resumed.
2.WaitOne(timeout) causes the thread to wait until either
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With