static async Task Main(string[] args) { // Setup everything we need to run the application. var comparerOptions = await BuildComparisonOptions(args); var statusFactory = new ExecutionStatusFactory(); var mainLoop = BuildMainLoop(statusFactory); // Print the intro splash. Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(ConsoleInterface.GetOpeningSplash()); // Run the main application loop. do { var executionStatus = statusFactory.ConstructNoOp(); try { executionStatus = await mainLoop.Execute(comparerOptions); } catch (Exception exception) { exception.WriteToConsole(); } if (executionStatus.IsTerminated) { break; } if (executionStatus.IsFaulted) { if (executionStatus.FaultedReason.IsSome) { executionStatus.FaultedReason.Value.WriteToConsole(); } else { Console.WriteLine("Unknown exception encountered."); } continue; } if (!executionStatus.IsFaulted) { executionStatus.PrintingInstructions(); } // Force the garbage collector to run, after each search session. // The idea being that collector will clean up any outstanding // resources from the run. GC.Collect(); } while (true); Console.WriteLine("Exiting..."); }