Async Task.Sleep() pauses everything? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Async Task.Sleep() pauses everything?

Async allows multiple codes/tasks to be runned at the same time. But when I do await Task.Sleep(1000); inside a function. It pauses all the tasks for 1second. Shouldn't only pause inside it's own function only? Also, is there anyway to make a code that pauses only a specific function instead of the whole task.

10th Mar 2017, 11:15 PM
Wen Qin
Wen Qin - avatar
3 Answers
0
You can create a news object that estends thread, so you can sweet only this object
12th Mar 2017, 8:38 AM
Giampaolo Bolzonella
Giampaolo Bolzonella - avatar
0
If it is C# use Thread.Threading.Sleep(100);
24th Apr 2017, 4:57 AM
Eldar Bakerman
0
I'm not sure but I think Task.Delay should work.
20th Jul 2017, 11:03 PM
axel