I want to program wait for a span of 1 second for the user input, if there is none then do some part of code, otherwise break out of the loop, i have an example below:
while (true)
{
while (!Console.KeyAvailable) {
Console.WriteLine("Waiting for an input");
Thread.Sleep(1000);
}
Console.WriteLine("Input made");
}
The problem is, that after the input is made Console.KeyAvailable property is still in true value, so it will be outputting "Input made" forever, is there any alternative to Console.KeyAvailable or how do i make it work more that once?