Open tholder opened 7 years ago
I hope I was not mistaken about the topic, and this same issue is mentioned here. I came across it when implementing key interception through SetWindowsHookEx:
[DllImport("user32.dll")]
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevel_KeyboardProc Ipfn, IntPtr hMod, uint dwThreadId);
The problem is that if there is "Thread.Sleep" inside the event handler or somewhere inside its code, then after a couple of clicks the event completely stops registering. In this library, I encountered the same behavior.
private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine("KeyPress: \t{0}", e.KeyChar);
Thread.Sleep(500);
}
It seems like you can't supress a keypress in the keydown event if there is any sort of delay?
Any idea what causes this?