void KeyboardHook_LockedDownKeyboardKeyPressed(object sender, KeyboardLockDownKeyPressedEventArgs e) { // Invoke is required here to avoid cross threading exceptions. Action a = () => textBoxMessages.AppendText(string.Format("Lockdown pressed event: {0}{1}", DateTime.Now, Environment.NewLine)); textBoxMessages.Invoke(a); }
/// <summary> /// Raises the KeyboardLockDownKeyPressed event by invoking each subscribed delegate asynchronously. /// </summary> /// <param name="pressedKeys">The keys that are pressed.</param> /// <param name="state">The state of the keys.</param> static void OnLockedDownKeyboardKeyPressed(KeysEx pressedKeys, KeyState state) { foreach (EventHandler <KeyboardLockDownKeyPressedEventArgs> pressedEvent in LockedDownKeyboardKeyPressed.GetInvocationList()) { var args = new KeyboardLockDownKeyPressedEventArgs(pressedKeys, state); AsyncCallback callback = ar => ((EventHandler <KeyboardLockDownKeyPressedEventArgs>)ar.AsyncState).EndInvoke(ar); pressedEvent.BeginInvoke(null, args, callback, pressedEvent); } }
/// <summary> /// Raises the KeyboardLockDownKeyPressed event by invoking each subscribed delegate asynchronously. /// </summary> /// <param name="pressedKeys">The keys that are pressed.</param> /// <param name="state">The state of the keys.</param> static void OnLockedDownKeyboardKeyPressed(KeysEx pressedKeys, KeyState state) { foreach (EventHandler<KeyboardLockDownKeyPressedEventArgs> pressedEvent in LockedDownKeyboardKeyPressed.GetInvocationList()) { var args = new KeyboardLockDownKeyPressedEventArgs(pressedKeys, state); AsyncCallback callback = ar => ((EventHandler<KeyboardLockDownKeyPressedEventArgs>)ar.AsyncState).EndInvoke(ar); pressedEvent.BeginInvoke(null, args, callback, pressedEvent); } }