public Task <long> Run(string runName) { task = Task.Run(() => { s.BuildId = s.Logger.Build_Init(s, runName); s.MainViewModel.BuildFullProgressBarMax = s.Plugins.Count; // Update project variables s.Project.UpdateProjectVariables(); while (true) { ReadyRunPlugin(s); // Run Main Section if (s.CurrentPlugin.Sections.ContainsKey(s.EntrySection)) { PluginSection mainSection = s.CurrentPlugin.Sections[s.EntrySection]; SectionAddress addr = new SectionAddress(s.CurrentPlugin, mainSection); s.Logger.LogStartOfSection(s, addr, 0, true, null, null); Engine.RunSection(s, new SectionAddress(s.CurrentPlugin, mainSection), new List <string>(), 1, false); s.Logger.LogEndOfSection(s, addr, 0, true, null); } // End of Plugin FinishRunPlugin(s); // OnPluginExit event callback { bool bakPassCurrentPluginFlag = s.PassCurrentPluginFlag; bool bakErrorHalt = s.ErrorHaltFlag; bool bakUserHalt = s.UserHaltFlag; bool bakCmdHalt = s.CmdHaltFlag; string eventParam = FinishEventParam(s); // Reset Halt Flags before running OnPluginExit // Otherwise only first command is executed s.PassCurrentPluginFlag = false; s.ErrorHaltFlag = false; s.UserHaltFlag = false; s.CmdHaltFlag = false; Engine.CheckAndRunCallback(s, ref s.OnPluginExit, eventParam, "OnPluginExit"); s.PassCurrentPluginFlag = bakPassCurrentPluginFlag; s.ErrorHaltFlag = bakErrorHalt; s.UserHaltFlag = bakUserHalt; s.CmdHaltFlag = bakCmdHalt; } if (s.Plugins.Count - 1 <= s.CurrentPluginIdx || s.RunOnePlugin || s.ErrorHaltFlag || s.UserHaltFlag || s.CmdHaltFlag) { // End of Build bool alertPassCurrentPluginFlag = s.PassCurrentPluginFlag; bool alertErrorHalt = s.ErrorHaltFlag; bool alertUserHalt = s.UserHaltFlag; bool alertCmdHalt = s.CmdHaltFlag; if (s.UserHaltFlag) { s.MainViewModel.PluginDescriptionText = "Build stop requested by user"; s.Logger.Build_Write(s, Logger.LogSeperator); s.Logger.Build_Write(s, new LogInfo(LogState.Info, "Build stop requested by user")); } string eventParam = FinishEventParam(s); // Reset Halt Flags before running OnBuildExit // Otherwise only first command is executed s.PassCurrentPluginFlag = false; s.ErrorHaltFlag = false; s.UserHaltFlag = false; s.CmdHaltFlag = false; // OnBuildExit event callback Engine.CheckAndRunCallback(s, ref s.OnBuildExit, eventParam, "OnBuildExit", true); if (alertUserHalt) { MessageBox.Show("Build Stopped by User", "Build Halt", MessageBoxButton.OK, MessageBoxImage.Information); } else if (alertErrorHalt) { MessageBox.Show("Build Stopped by Error", "Build Halt", MessageBoxButton.OK, MessageBoxImage.Information); } else if (alertCmdHalt) { MessageBox.Show("Build Stopped by Halt Command", "Build Halt", MessageBoxButton.OK, MessageBoxImage.Information); } else if (alertPassCurrentPluginFlag) { MessageBox.Show("Build Stopped by Exit Command", "Build Halt", MessageBoxButton.OK, MessageBoxImage.Information); } break; } // Run Next Plugin s.CurrentPluginIdx += 1; s.CurrentPlugin = s.Plugins[s.CurrentPluginIdx]; s.PassCurrentPluginFlag = false; } s.Logger.Build_Finish(s); return(s.BuildId); }); return(task); }