src/Lurker/Helpers/KeyboardHelper.cs
/// <summary>
/// Waits for next key asynchronous.
/// </summary>
/// <returns>The next key press.</returns>
Waits for next key asynchronous.
Waits for next key asynchronous .
public Task<Winook.KeyboardMessageEventArgs> WaitForNextKeyAsync()
        {
            var taskCompletionSource = new TaskCompletionSource<Winook.KeyboardMessageEventArgs>();
            var hook = new Winook.KeyboardHook(ProcessLurker.CurrentProcessId);
            EventHandler<Winook.KeyboardMessageEventArgs> handler = default;
            handler = (object s, Winook.KeyboardMessageEventArgs e) =>
            {
                if (e.Direction == Winook.KeyDirection.Up)
                {
                    taskCompletionSource.SetResult(e);
                    hook.MessageReceived -= handler;
                    hook.Dispose();
                }
            };
            hook.MessageReceived += handler;
            hook.InstallAsync().Wait();
            return taskCompletionSource.Task;
        }
public Task < Winook . KeyboardMessageEventArgs > WaitForNextKeyAsync ( ) { var taskCompletionSource = new TaskCompletionSource < Winook . KeyboardMessageEventArgs > ( ) ; var hook = new Winook . KeyboardHook ( ProcessLurker . CurrentProcessId ) ; EventHandler < Winook . KeyboardMessageEventArgs > handler = default ; handler = ( object s , Winook . KeyboardMessageEventArgs e ) => { if ( e . Direction == Winook . KeyDirection . Up ) { taskCompletionSource . SetResult ( e ) ; hook . MessageReceived -= handler ; hook . Dispose ( ) ; } } ; hook . MessageReceived += handler ; hook . InstallAsync ( ) . Wait ( ) ; return taskCompletionSource . Task ; }
Waits for next key asynchronous.
Waits for next key asynchronous .
The next key press.
The next key press .