Difference between task.delay and thread.sleep c#
The text of this thread is not in this database — only its details are. Read it on the old site: Difference between task.delay and thread.sleep c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Jithu ThomasRank #437 · 5.7K reputationPosted Feb 12, 2024, 6:43 AM EST
Task.DelayandThread.Sleepin C# are used for asynchronous and synchronous delays, respectively.Task.Delayis part of the Task Parallel Library and doesn't block the calling thread, making it suitable for asynchronous operations in async methods. It returns a Task representing the delay. On the other hand,Thread.Sleeppauses the entire thread for the specified time, causing synchronous blocking. It's typically used in non-async contexts and can introduce responsiveness issues in GUI applications.Task.Delayis more suitable for modern asynchronous programming, whileThread.Sleepis used for synchronous blocking scenarios.Vishal YelveRank #178 · 13.6K reputationPosted Feb 12, 2024, 6:54 AM EST
Hi Abhishek,
do refer below link
https://code-maze.com/csharp-thread-sleep-vs-task-delay/