ConsoleApp Freeze user input for 1sec [Answered]
I need to freeze user input for 1 second after the last user input.
What i use for the input in a do while loop is this:
input = Console.ReadKey(true);
Then I call the method:
public void timeout(){
Stopwatch sw = new Stopwatch();
Random random = new Random();
var ranNum = random.Next(650, 950);
sw.Start();
while (true)
{
if (sw.Elapsed.TotalMilliseconds > ranNum)
{
break;
}
}
sw.Stop();
}
Problem is that it still reads user input while the timout is happening. System thread freeze also do not work. Please advice!
What i use for the input in a do while loop is this:
input = Console.ReadKey(true);
Then I call the method:
public void timeout(){
Stopwatch sw = new Stopwatch();
Random random = new Random();
var ranNum = random.Next(650, 950);
sw.Start();
while (true)
{
if (sw.Elapsed.TotalMilliseconds > ranNum)
{
break;
}
}
sw.Stop();
}
Problem is that it still reads user input while the timout is happening. System thread freeze also do not work. Please advice!