I am trying to add a 1 second delay inside a loop.
What I have done is:
public void Delay()
{
DateTime end = DateTime.Now.AddSeconds(1);
while (DateTime.Now <= end)
{
//code here
}
}
and I add the Delay() in my loop.
Is this the best/acceptable way of doing this or can someone recommend a better way?
Thread.Sleep(1000)
. It stops the execution of the thread for 1000ms.