private Task PerformConsoleWrite(CachedConsoleOutputProxy console) { if (Dispatcher.HasThreadAccess) { console.WriteLines(this); return(Task.CompletedTask); } return(Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => console.WriteLines(this)).AsTask()); }
private async void OnCoreWindowKeyDown(CoreWindow sender, KeyEventArgs args) { if (VirtualKey.Enter == args.VirtualKey && IsFocused) { var text = input.Text; if (String.IsNullOrEmpty(text)) { return; } var processor = CommandProcessor; if (null == processor) { return; } var console = new CachedConsoleOutputProxy(); try { var result = await processor.TryExecuteAsync(text, console); if (result) { } else { throw new Exception(); } ClearInput(); } catch (Exception exception) { var output = (IConsoleOutput)console; output.WriteLine("Error: " + exception.Message, LogLevel.Error); input.SelectAll(); } await PerformConsoleWrite(console); args.Handled = true; } }