/// <summary> /// Starts debugger if not already started. Prints basic info if required. /// </summary> /// <param name="toolName">Name of tool where debugging is to be started from.</param> public static void StartDebugger(string toolName) { string appender = ""; if (DebugOutput.rtb == null) { UpdateTimer = new Timer(); // KFreon: Deal with file in use for (int i = 0; i < 10; i++) { try { fs = new FileStream(Path.GetDirectoryName(Application.ExecutablePath) + "\\DebugOutput" + appender + ".txt", FileMode.Create, FileAccess.Write); break; } catch { var t = i; appender = t.ToString(); } } if (fs == null) MessageBox.Show("Failed to open any debug output files. Disk cached debugging disabled for this session."); // KFreon: Thread debugger Task.Factory.StartNew(() => { DebugWindow debugger = new DebugWindow(); debugger.ShowDialog(); }, TaskCreationOptions.LongRunning); // KFreon: Print basic info System.Threading.Thread.Sleep(200); DebugOutput.PrintLn("-----New Execution of " + toolName + "-----"); DebugOutput.PrintLn("Build Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); PrintLn("Using file: DebugOutput" + appender + ".txt"); DebugOutput.PrintLn("Using debug file: DebugOutput" + appender + ".txt"); } else DebugOutput.PrintLn("-----New Execution of " + toolName + "-----"); }