private void TryPerformEntryOperation(MenuEntry entry) { try { Console.WriteLine(); IOperation operation = entry.CreateNewOperation(new ConsoleUserInterface()); operation.Run(); if (operation.IsRebootRecommended) { ConsoleHelpers.WriteLine("\nA system reboot is recommended.", ConsoleColor.Cyan); rebootFlag.SetRebootRecommended(); } if (entry.ShouldQuit) { exitRequested = true; return; } Console.Write("\nDone! "); } catch (Exception exc) { ConsoleHelpers.WriteLine($"Operation failed: {exc.Message}", ConsoleColor.Red); #if DEBUG ConsoleHelpers.WriteLine(exc.StackTrace, ConsoleColor.Red); #endif Console.WriteLine(); } ConsoleHelpers.FlushStandardInput(); Console.WriteLine("Press a key to return to the main menu"); Console.ReadKey(); }
private void TryPerformEntryOperation(MenuEntry entry) { try { Console.WriteLine(); IOperation operation = entry.CreateNewOperation(new ConsoleUserInterface()); operation.Run(); if (operation.IsRebootRecommended) { ConsoleHelpers.WriteLine("\n建议系统重启一下.", ConsoleColor.Cyan); rebootFlag.SetRebootRecommended(); } if (entry.ShouldQuit) { exitRequested = true; return; } Console.Write("\n完成! "); } catch (Exception exc) { ConsoleHelpers.WriteLine($"修改失败: {exc.Message}", ConsoleColor.Red); #if DEBUG ConsoleHelpers.WriteLine(exc.StackTrace, ConsoleColor.Red); #endif Console.WriteLine(); } ConsoleHelpers.FlushStandardInput(); Console.WriteLine("按任意键返回主菜单"); Console.ReadKey(); }