private async Task DoWork() { try { _hostApplicationLifetime.ApplicationStarted.WaitHandle.WaitOne(); await _consoleService.RunAsync(); } catch (Exception ex) { _printingService.WriteLine($"ERROR: {ex.Message}"); _printingService.WriteLine($"StackTrace: {ex.StackTrace}"); _printingService.WriteLine("Press aby key to terminate..."); Console.ReadKey(); } finally { _hostApplicationLifetime.StopApplication(); } }
private async Task <bool> MainMenu() { _printer.Clear(); _printer.WriteLine("CHANNEL ENGINE CONSOLE\n"); _printer.WriteLine("Choose option:"); _printer.WriteLine("1) Get all orders with status"); _printer.WriteLine("0) EXIT"); _printer.WriteLine(); var key = Console.ReadKey().Key; switch (key) { case ConsoleKey.D1: await ShowAllOrdersWithStatus(); return(true); case ConsoleKey.D0: return(false); default: _printer.WriteLine(); _printer.WriteLine("Invalid option selected. Try again."); Console.ReadKey(); return(true); } }