If I write a Thread.Sleep(10000) in my code, does that count as taking a break at work?
If I write a Thread.Sleep(1000) in my code, does that count as taking
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Praveen KumarRank #4 · 79.9K reputationPosted Jun 2, 2025, 5:26 AM EDT
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 Hess114 reputationPosted May 31, 2025, 5:24 PM EDT
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.