diff --git a/src/Rasa.Utils/Commands/CommandProcessor.cs b/src/Rasa.Utils/Commands/CommandProcessor.cs index 7bf2cab0..9c26d030 100644 --- a/src/Rasa.Utils/Commands/CommandProcessor.cs +++ b/src/Rasa.Utils/Commands/CommandProcessor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading; +using System.Threading.Tasks; namespace Rasa.Commands { @@ -8,9 +9,9 @@ public static class CommandProcessor { private static readonly Dictionary> Commands = new Dictionary>(); - public static void ProcessCommand(CancellationToken stopToken) + public static async Task ProcessCommand(CancellationToken stopToken) { - var command = ReadCommand(stopToken); + var command = await ReadCommand(stopToken); if (string.IsNullOrWhiteSpace(command)) return; @@ -27,7 +28,7 @@ public static void ProcessCommand(CancellationToken stopToken) Logger.WriteLog(LogType.Command, $"Invalid command: {command}"); } - private static string ReadCommand(CancellationToken stopToken) + private static async Task ReadCommand(CancellationToken stopToken) { var command = string.Empty; while (!stopToken.IsCancellationRequested) @@ -41,12 +42,15 @@ private static string ReadCommand(CancellationToken stopToken) return command; case ConsoleKey.Backspace: command = command.Substring(0, command.Length - 1); + Console.Write("\b \b"); break; default: command += key.KeyChar; break; } } + + await Task.Delay(25, stopToken); } return null; } diff --git a/src/Rasa.Utils/Hosting/RasaHost.cs b/src/Rasa.Utils/Hosting/RasaHost.cs index a42098a3..e5c20545 100644 --- a/src/Rasa.Utils/Hosting/RasaHost.cs +++ b/src/Rasa.Utils/Hosting/RasaHost.cs @@ -50,7 +50,7 @@ private async Task ProcessCommands(CancellationToken stoppingToken) while (_rasaServer.Running && !stoppingToken.IsCancellationRequested) { - CommandProcessor.ProcessCommand(stoppingToken); + await CommandProcessor.ProcessCommand(stoppingToken); await Task.Delay(25, stoppingToken); } }