Qus:    How to send a thread for sleep?
Nov 27, 2020 13:46 2 Answers Views: 650 RAMU

  Use Thread.Sleep method.



Example -



static void Main()

{

for (int i = 0; i < 5; i++)

{

Console.WriteLine("Sleep for 2 seconds.");

Thread.Sleep(2000);

}

}

Prev Next
Answers (2)
PARTH Nov 28, 2020 02:41
Answer:   Use Thread.Sleep method.

Example -

static void Main()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Sleep for 2 seconds.");
Thread.Sleep(2000);
}
}

SWEETY Nov 28, 2020 09:56
Answer:   By using Thread.sleep(), we can send a thread to sleep according to the given time. Sleep () method can be blocked the current thread for the specified number of milliseconds. In other words We can include specific time via thread.sleep() method as follows.
Thread.Sleep (TimeSpan.FromHours (1)); // sleep for 1 hour
Thread.Sleep (1000); // sleep for 1000

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect