Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Modified exit logic for console app
  • Loading branch information
jeremybytes committed Sep 7, 2017
1 parent ed2efd0 commit 3810d42
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Program.cs
Expand Up @@ -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<List<Person>> peopleTask = repository.GetAsync(tokenSource.Token);
Expand Down Expand Up @@ -52,17 +52,20 @@ private static void HandleCancellation(Task<List<Person>> 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;
}
}
}
}

0 comments on commit 3810d42

Please sign in to comment.