Home > OS >  C# Console Application (Print to screen over time in console application in c sharp)
C# Console Application (Print to screen over time in console application in c sharp)

Time:01-30

I want to print over time without printing directly to the screen. For example, the program says "Hello" every 3 seconds.

Here's what I have so far:

Console.WriteLine("Hello");
Console.WriteLine("Hello");
Console.WriteLine("Hello");
Console.ReadLine();

How can I do this?

CodePudding user response:

I believe you will want to use the C# Timer Class. The example in the documentation is pretty solid and shows a 2 second interval.

CodePudding user response:

Console.WriteLine("Hello");
Thread.Sleep(3000);
Console.WriteLine("Hello");
Thread.Sleep(3000);
Console.WriteLine("Hello");
Console.ReadLine();
  •  Tags:  
  • Related