I found out that Thread.Sleep() is a lot useful when simulating long-lasting tasks and cancelling them in a graceful way (avoiding Thread.Abort()), On the other hand, I've read that using Thread.Sleep() for waiting other operations to end is a bad practice (we have Thread.Join() for doing it). I want to know if there's any application of Thread.Sleep() in a real production code/situation.
Here are a few:
Sleep(0) induces a context switch, yielding to another waiting thread of equal or higher priority.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