Answers for "c# await sleep"

C#
14

c# Sleep

using System.Threading;

static void Main()
{
  //do stuff
  Thread.Sleep(5000) //will sleep for 5 sec
}
Posted by: Guest on March-02-2020
3

c# async sleep

// Async
await Task.Delay(1000); //when you want a logical delay without blocking the current thread
// Not Async
Thread.Sleep(1000) //when you want to block the current thread.
Posted by: Guest on August-22-2020

C# Answers by Framework

Browse Popular Code Answers by Language