/// <summary> /// Execute the method that save the output /// </summary> /// <param name="exception">set it true if you call this method on an unkown error</param> public static void Finish(Boolean exception) { //stop the stopwatch _globalTime.Stop(); //save all info that will be used by OutputUtils to write global info OutputUtils.Global.xmlNode = ConfigUtils.Global; OutputUtils.Global.endTime = DateTime.Now; OutputUtils.Global.duration = _globalTime.ElapsedMilliseconds; //close window(s) Thread.Sleep(2000); string windowToCloseRegEx = ConfigUtils.WindowTitleToClose; if (windowToCloseRegEx != "") { SystemUtils.User32.CloseWindow(windowToCloseRegEx); } Thread.Sleep(2000); if (_processToKillRegEx != "") { processesAfterAlexa = SystemUtils.ProcessUtils.GetUserProcessesByRegEx(userDomain, userName, _processToKillRegEx); foreach (UInt32 pidAfterAlexa in processesAfterAlexa) { bool pidFound = false; foreach (UInt32 pidBeforeAlexa in processesBeforeAlexa) { if (pidAfterAlexa == pidBeforeAlexa) { pidFound = true; } } if (pidFound == false) { SystemUtils.ProcessUtils.processesToKill.Add(pidAfterAlexa); } } //loop through all processes to kill foreach (UInt32 pidToKill in SystemUtils.ProcessUtils.processesToKill) { //kill the process SystemUtils.ProcessUtils.KillProcess(pidToKill); } } //save the output file and exit OutputUtils.Finish(exception); //if exit is true then exit with exitcode 3 //if (exit) Environment.Exit(3); }