How to add a delay for a 2 seconds in C#

1 Answer

0 votes
using System;
using System.Threading;

public class Program
{
	static void Main() {
		try {
			Console.WriteLine("Counting...");

			int milliseconds = 2000;
            Thread.Sleep(milliseconds);

			Console.WriteLine("END");
		}
		catch (Exception e) {
			Console.WriteLine(e.ToString());
		}
	}
}




/*
 
run:
 
Counting...
END
 
*/

 



answered Jul 27, 2022 by avibootz

Related questions

1 answer 138 views
1 answer 186 views
1 answer 148 views
1 answer 148 views
1 answer 228 views
1 answer 141 views
...