If I write a Thread.Sleep(10000) in my code, does that count as taking a break at work?
Loading
If I write a Thread.Sleep(10000) in my code, does that count as taking a break at work?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Praveen KumarPosted Jun 2, 2025, 9:26 AM
Nice try — but no, writing Thread.Sleep(10000) in your code does not count as taking a break at work (at least not in a way your HR would approve).
It tells the computer to rest, not the developer.
Thread.Sleep(10000) ≠ coffee break.
It’s a nap for the code, not for the coder.
Matthew HessPosted May 31, 2025, 9:24 PM
No, because Thread.Sleep() blocks execution of the current thread meaning you would be stuck in your chair. I suggest you use await Task.Delay() instead, which is asynchronous and allows the current thread to return to the thread pool and be re-used. That way you can go get a cup of coffee and consider it a more satisfying, proper break.