diff --git a/Program.cs b/Program.cs index 5ab7be5..16d3c0b 100644 --- a/Program.cs +++ b/Program.cs @@ -13,7 +13,7 @@ static void Main(string[] args) { tokenSource = new CancellationTokenSource(); - Console.WriteLine("One Moment Please (press 'x' to Cancel)"); + Console.WriteLine("One Moment Please ('x' to Cancel, 'q' to Quit)"); var repository = new PersonRepository(); Task> peopleTask = repository.GetAsync(tokenSource.Token); @@ -52,17 +52,20 @@ private static void HandleCancellation(Task> task) private static void HandleExit() { - ExitLoop: - if (Console.ReadKey().Key == ConsoleKey.X) - { - tokenSource.Cancel(); - goto ExitLoop; - } - else - { - Console.WriteLine("Waiting..."); - goto ExitLoop; - } + while (true) + switch (Console.ReadKey().Key) + { + case ConsoleKey.X: + tokenSource.Cancel(); + break; + case ConsoleKey.Q: + Console.WriteLine(); + Environment.Exit(0); + break; + default: + Console.WriteLine("Waiting..."); + break; + } } } }