AEMManager.AemInstance.GetInstanceJavaProcess C# (CSharp) Method

GetInstanceJavaProcess() public method

public GetInstanceJavaProcess ( ) : Process
return System.Diagnostics.Process
        public Process GetInstanceJavaProcess()
        {
            Process instanceProcess = null;

              try {

            // try to find matching process name
            /*
            -- this was supposed to support finding running instance again when AEM manager was stopped
            -- but this does not seem to work any longer, and even creates performance issues on some machines
            -- so, deactivate it for now
            foreach (Process process in Process.GetProcesses()) {
              if (process.MainWindowTitle.Equals(this.Name)
              || process.MainWindowTitle.EndsWith("\\" + this.Name + ".lnk")) {
            instanceProcess = process;
            break;
              }
            }
            */

            // if none found use process associated with instance
            if (instanceProcess == null) {
              instanceProcess = this.JavaProcess;
            }

            // check if process is still alive
            if (instanceProcess != null) {
              if (instanceProcess.HasExited) {
            instanceProcess = null;
            mJavaProcess = null;
              }
              else {
            instanceProcess.Refresh();
              }
            }

              }
              catch (InvalidOperationException ex) {
            mLog.Warn("Error checking process state of '" + this.Name + "'.", ex);
            instanceProcess = null;
            mJavaProcess = null;
              }

              return instanceProcess;
        }

Usage Example

Example #1
0
        private static void ControlKillInstance(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            Process process = instance.GetInstanceJavaProcess();

            if (process != null)
            {
                KillProcessAndChildrens(process.Id, instance);
            }
        }
All Usage Examples Of AEMManager.AemInstance::GetInstanceJavaProcess