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#
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#
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.
Jithu ThomasPosted Feb 12, 2024, 11:43 AM
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 YelvePosted Feb 12, 2024, 11:54 AM
Hi Abhishek,
do refer below link
https://code-maze.com/csharp-thread-sleep-vs-task-delay/