c# timer wait code example
Example 1: c# wait for seconds
using System;
using System.Threading;
class Example
{
static void Main()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Sleep for 2 seconds.");
Thread.Sleep(2000);
}
Console.WriteLine("Main thread exits.");
}
}
Example 2: how to wait in c#
System.Threading.Thread.Sleep(Milliseconds);
Example 3: how to delay execution in c#
int sleepTime = 1000;
Task.Delay(sleepTime).Wait();
Thread.Sleep(sleepTime);
Example 4: c# wait seconds
Thread.Sleep(2000);
Task.Delay(2000);