Example #1
0
        public static bool KillProcess(int pid)
        {
            NSRunningApplication runningApp = NSRunningApplication.GetRunningApplication(pid);

            if (runningApp == null)
            {
                return(false);
            }

            return(runningApp.ForceTerminate());
        }
Example #2
0
        public void DisplayExistingUI()
        {
            var thisProcess = Process.GetCurrentProcess();
            var processes   = Process.GetProcessesByName(thisProcess.ProcessName).Where(p => p.Id != thisProcess.Id);

            foreach (Process runningProcess in processes)
            {
                NSRunningApplication app = NSRunningApplication.GetRunningApplication(runningProcess.Id);
                app.Activate(NSApplicationActivationOptions.ActivateAllWindows);
            }
        }
Example #3
0
        public static bool TerminateApplication(int pid, bool waitForExit = true)
        {
            var app = NSRunningApplication.GetRunningApplication(pid);

            if (app == null)
            {
                return(false);
            }

            if (app.Terminate())
            {
                while (null != NSRunningApplication.GetRunningApplication(pid))
                {
                }
            }
            return(true);
        }
        public static bool Activate(int pid, int wait = 5000)
        {
            NSRunningApplication app = null;

            for (; wait > 0; wait -= 100)
            {
                if (app == null)
                {
                    app = NSRunningApplication.GetRunningApplication(pid);
                }

                if (app != null && app.FinishedLaunching)
                {
                    if (app.Activate(NSApplicationActivationOptions.ActivateIgnoringOtherWindows))
                    {
                        return(true);
                    }
                }

                NSThread.SleepFor(0.1);
            }
            return(false);
        }
Example #5
0
 public static bool IsRunning(int pid)
 {
     return(NSRunningApplication.GetRunningApplication(pid) != null);
 }