System.Diagnostics.ProcessManager.IsProcessRunning C# (CSharp) Method

IsProcessRunning() public static method

Gets whether the process with the specified ID on the specified machine is currently running.
public static IsProcessRunning ( int processId, string machineName ) : bool
processId int The process ID.
machineName string The machine name.
return bool
        public static bool IsProcessRunning(int processId, string machineName)
        {
            ThrowIfRemoteMachine(machineName);
            return IsProcessRunning(processId);
        }

Same methods

ProcessManager::IsProcessRunning ( int processId ) : bool
ProcessManager::IsProcessRunning ( int processId, int processIds ) : bool

Usage Example

Exemplo n.º 1
0
        /// <devdoc>
        ///    <para>
        ///       Returns a new <see cref='System.Diagnostics.Process'/> component given a process identifier and
        ///       the name of a computer in the network.
        ///    </para>
        /// </devdoc>
        public static Process GetProcessById(int processId, string machineName)
        {
            if (!ProcessManager.IsProcessRunning(processId, machineName))
            {
                throw new ArgumentException(SR.Format(SR.MissingProccess, processId.ToString()));
            }

            return(new Process(machineName, ProcessManager.IsRemoteMachine(machineName), processId, null));
        }