C# or .NET Flushing Keyboard Buffer
while (Console.KeyAvailable) { Console.ReadKey(true); }
Set KeyPreview
on the Form to true
, then catch the KeyPress
event and set e.Handled
to true
if cancel was clicked.
EDIT: Catch the Form's KeyPress event