AcTools.Utils.Helpers.ProcessWrapper.WaitForExitSafe C# (CSharp) Method

WaitForExitSafe() public method

public WaitForExitSafe ( int milliseconds ) : bool
milliseconds int
return bool
        public bool WaitForExitSafe(int milliseconds) {
            var handle = IntPtr.Zero;
            bool exited;
            ProcessWaitHandle processWaitHandle = null;

            try {
                handle = GetProcessHandle(Kernel32.ProcessAccessFlags.Synchronize, false);
                if (handle == IntPtr.Zero || handle == new IntPtr(-1)) {
                    exited = true;
                } else {
                    processWaitHandle = new ProcessWaitHandle(handle);
                    if (processWaitHandle.WaitOne(milliseconds, false)) {
                        exited = true;
                        _signaled = true;
                    } else {
                        exited = false;
                        _signaled = false;
                    }
                }
            } finally {
                processWaitHandle?.Close();
                ReleaseProcessHandle(handle);
            }

            if (exited && _watchForExit) {
                RaiseOnExited();
            }

            return exited;
        }

Same methods

ProcessWrapper::WaitForExitSafe ( ) : void