public static JobReturnStatus RunJob(bool bFromMenu = false) { bool bWasStartedManually = false; bool bThrewException = false; bool bDone = false; try { if (!IgorJobConfig.GetIsRunning()) { IgorDebug.CoreLog("Job is starting!"); IgorAssert.StartJob(); CheckForNamedJobFlag(); } if (IgorJobConfig.GetWasMenuTriggered()) { bWasStartedManually = true; } else { bWasStartedManually = bFromMenu; IgorJobConfig.SetWasMenuTriggered(bWasStartedManually); } if (!IgorJobConfig.GetIsRunning() || EnabledModules.Count == 0) { RegisterAllModules(); } if (!IgorJobConfig.GetIsRunning() || ActiveModulesForJob.Count == 0) { ProcessArgs(); } if (ExecuteSteps()) { IgorJobConfig.SetIsRunning(false); bDone = true; } } catch (Exception e) { IgorDebug.CoreLogError("Caught exception while running the job. Exception is " + (e == null ? "NULL exception!" : e.ToString() + (e.InnerException == null ? "\n\nNULL inner exception." : ("\n\nInner: " + e.InnerException.ToString())))); bThrewException = true; } finally { if (bThrewException || bDone) { Cleanup(); } } JobReturnStatus NewStatus = new JobReturnStatus(); NewStatus.bDone = bDone; NewStatus.bFailed = bThrewException || IgorAssert.HasJobFailed(); NewStatus.bWasStartedManually = bWasStartedManually; return(NewStatus); }