C# or .NET Flushing Keyboard Buffer

后端 未结 7 1359
太阳男子
太阳男子 2021-01-12 08:34

How do I flush the keyboard buffer in C# using Windows Forms?

I have a barcode scanner which acts like a keyboard. If a really long barcode is scanned and the cancel

7条回答
  •  迷失自我
    2021-01-12 09:30

    I'm not sure you can do this. The keystrokes go into the event queue for the main event loop. Any action you take to cancel these keystrokes will be placed in the queue after the keystrokes.

    The event loop will only get to your cancel action after the keystrokes have been processed. You can only cancel the keystrokes based on some event that happens in the middle of the keystroke sequence.

提交回复
热议问题