I have a console application which stores my input when calling ReadKey()
before that line executes:
static void Main(string[] args)
{
Console.WriteLine("Beginning long pause...");
Thread.Sleep(6000);
var input = Console.ReadKey();
Console.WriteLine("You pressed: " + input.Key.ToString());
Console.ReadLine();
}
* Small note: You'll need to add using System.Threading;
.
Now, set a breakpoint on var input = Console.ReadKey();
. Run the application and immediately press any key. After a few seconds, the breakpoint will trigger. Continue, and the application will print out the key you pressed before the breakpoint triggered.
How / why does this happen, and how can I make it so my application won't "remember" any input until ReadKey()
actually executes?