AEMManager.AemActions.ControlStartInstance C# (CSharp) Method

ControlStartInstance() private static method

private static ControlStartInstance ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private static void ControlStartInstance(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);
              if (instance == null) {
            return;
              }

              if (instance.CurrentBundleStatus == BundleStatus.UNKNOWN
              || instance.CurrentBundleStatus == BundleStatus.STARTING_STOPPING
              || instance.CurrentBundleStatus == BundleStatus.RUNNING) {
            if (MessageBox.Show("The instance seems to be running already.\n"
            + "Press OK to continue starting the instance, it may fail.",
            "Start Instance", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)==DialogResult.Cancel) {
              return;
            }
              }

              string executable = "cmd";
              string aemInstanceArguments = BuildCommandLineArguments(instance);
              string arguments = "/c \"" + instance.JavaExecutable + "\" " + aemInstanceArguments;

              // add jprofiler path to current applications path to make sure spawned process gets it as well
              if (instance.JProfiler && (instance.JProfilerPort > 0)) {
            string path = System.Environment.GetEnvironmentVariable("Path");
            if (!path.Contains(AEMManager.Properties.Settings.Default.JProfilerPath)) {
              path += ";" + AEMManager.Properties.Settings.Default.JProfilerPath;
              System.Environment.SetEnvironmentVariable("Path", path);
            }
              }

              bool isConsoleOutputWindow = instance.ConsoleOutputWindow.Visible;
              if (!isConsoleOutputWindow) {
            // show and hide console window again when it is not shown already - to prevent deadlock that occured sometimes stopping instances (DINT-349)
            instance.ConsoleOutputWindow.Show();
              }
              instance.ConsoleOutputWindow.InitStartProcess(instance.PathWithoutFilename, instance.JavaExecutable, aemInstanceArguments);

              instance.JavaProcess = ExecuteCommand(instance.PathWithoutFilename, executable, arguments, instance.Name, instance.ShowInstanceWindow, "aem.ico", false, instance);
              instance.JavaProcessVisible = instance.ShowInstanceWindow;

              if (!isConsoleOutputWindow) {
            instance.ConsoleOutputWindow.Hide();
              }
        }