/// <summary> /// Handles console commands /// </summary> /// <param name="TM">Thread Manager</param> /// <returns>No return</returns> public static IEnumerable <ThreadInfo> HandleConsoleRequests(ThreadManager TM) { var currentThread = TM.CurrentThread; while (true) { yield return(TM.WaitForConsole(currentThread)); string request = TM.GetResult <string>(currentThread); try { switch (request) { case "help": Console.WriteLine("update\nstatus\nexecutions\nqueues\nthreads\ndirections\nexit"); break; case "update": UpdateServerVersion(); break; case "status": TM.WriteExecutionStatus(); TM.WriteQueueStatus(); TM.WriteThreadStatus(); DirectionsFinder.WriteStatus(); break; case "executions": TM.WriteExecutionStatus(); break; case "queues": TM.WriteQueueStatus(); break; case "threads": TM.WriteThreadStatus(); break; case "directions": DirectionsFinder.WriteStatus(); break; case "exit": System.Environment.Exit(0); break; default: Console.WriteLine("Invalid request."); break; } } catch (Exception ex) { Console.WriteLine("An exception occurred: {0}\nStack trace:\n{1}", ex.Message, ex.StackTrace); } Console.WriteLine(); } }