C# Class System.Diagnostics.Process

Inheritance: System.ComponentModel.Component
Show file Open project: dotnet/corefx Class Usage Examples

Private Properties

Property Type Description
BootTimeToDateTime System.DateTime
BuildCommandLine StringBuilder
CloseCore void
CloseMainWindowCore bool
ConfigureAfterProcessIdSet void
CreateEnvp string[]
CreatePipe void
CreatePipeWithSecurityAttributes void
EnsureHandleCountPopulated void
EnvironmentVariablesToByteArray byte[]
GetCurrentProcessId int
GetCurrentProcessRUsage Interop.libproc.rusage_info_v3
GetEncoding System.Text.Encoding
GetExePath string
GetMainWindowTitle string
GetProcessHandle Microsoft.Win32.SafeHandles.SafeProcessHandle
GetProcessHandle Microsoft.Win32.SafeHandles.SafeProcessHandle
GetProcessHandle Microsoft.Win32.SafeHandles.SafeProcessHandle
GetProcessTimes System.Diagnostics.ProcessThreadTimes
GetStat Interop.procfs.ParsedStat
GetWaitState System.Diagnostics.ProcessWaitState
GetWorkingSetLimits void
IsRespondingCore bool
OpenStream System.IO.FileStream
ParseArgumentsIntoList void
ParseArgv string[]
RefreshCore void
ResolvePath string
SetPrivilege void
SetWorkingSetLimitsCore void
Start Process
Start Process
Start System.Diagnostics.Process
Start System.Diagnostics.Process
StartCore bool
TicksToTimeSpan System.TimeSpan
UpdateHasExited void
WaitForExitCore bool
WaitForInputIdleCore bool

Public Methods

Method Description
BeginErrorReadLine ( ) : void
BeginOutputReadLine ( ) : void
CancelErrorRead ( ) : void
CancelOutputRead ( ) : void
Close ( ) : void
CloseMainWindow ( ) : bool
EnterDebugMode ( ) : void

Puts a Process component in state to interact with operating system processes that run in a special mode by enabling the native property SeDebugPrivilege on the current thread.

GetCurrentProcess ( ) : System.Diagnostics.Process
GetProcessById ( int processId ) : System.Diagnostics.Process
GetProcessById ( int processId, string machineName ) : System.Diagnostics.Process
GetProcesses ( ) : System.Diagnostics.Process[]
GetProcesses ( string machineName ) : System.Diagnostics.Process[]
GetProcessesByName ( string processName, string machineName ) : System.Diagnostics.Process[]

Creates an array of Process components that are associated with process resources on a remote computer. These process resources share the specified process name.

GetProcessesByName ( string processName ) : System.Diagnostics.Process[]
GetProcessesByName ( string processName, string machineName ) : System.Diagnostics.Process[]
Kill ( ) : void

Stops the associated process immediately.

LeaveDebugMode ( ) : void

Takes a Process component out of the state that lets it interact with operating system processes that run in a special mode.

Process ( )
Refresh ( ) : void
Start ( System startInfo ) : System.Diagnostics.Process
Start ( string fileName ) : System.Diagnostics.Process
Start ( string fileName, string arguments ) : System.Diagnostics.Process
Start ( ) : bool
ToString ( ) : string
WaitForExit ( int milliseconds ) : bool
WaitForExit ( ) : void
WaitForInputIdle ( ) : bool
WaitForInputIdle ( int milliseconds ) : bool

Protected Methods

Method Description
Dispose ( bool disposing ) : void
OnExited ( ) : void

Private Methods

Method Description
BootTimeToDateTime ( System.TimeSpan timespanAfterBoot ) : System.DateTime

Computes a time based on a number of ticks since boot.

BuildCommandLine ( string executableFileName, string arguments ) : StringBuilder
CloseCore ( ) : void

Additional logic invoked when the Process is closed.

CloseMainWindowCore ( ) : bool
ConfigureAfterProcessIdSet ( ) : void

Additional configuration when a process ID is set.

CreateEnvp ( ProcessStartInfo psi ) : string[]

Converts the environment variables information from a ProcessStartInfo into an envp array.

CreatePipe ( SafeFileHandle &parentHandle, SafeFileHandle &childHandle, bool parentInputs ) : void
CreatePipeWithSecurityAttributes ( SafeFileHandle &hReadPipe, SafeFileHandle &hWritePipe, Interop &lpPipeAttributes, int nSize ) : void
EnsureHandleCountPopulated ( ) : void
EnvironmentVariablesToByteArray ( string>.Dictionary sd ) : byte[]
GetCurrentProcessId ( ) : int

Gets the ID of the current process.

GetCurrentProcessRUsage ( ) : Interop.libproc.rusage_info_v3
GetEncoding ( int codePage ) : Encoding
GetExePath ( ) : string

Gets the path to the current executable, or null if it could not be retrieved.

GetMainWindowTitle ( ) : string
GetProcessHandle ( ) : SafeProcessHandle

Gets a short-term handle to the process, with the given access. If a handle exists, then it is reused. If the process has exited, it throws an exception.

GetProcessHandle ( int access ) : SafeProcessHandle
GetProcessHandle ( int access, bool throwIfExited ) : SafeProcessHandle
GetProcessTimes ( ) : System.Diagnostics.ProcessThreadTimes

Gets timing information for the current process.

GetStat ( ) : Interop.procfs.ParsedStat

Reads the stats information for this process from the procfs file system.

GetWaitState ( ) : System.Diagnostics.ProcessWaitState

Gets the wait state for this Process object.

GetWorkingSetLimits ( IntPtr &minWorkingSet, IntPtr &maxWorkingSet ) : void

Get the minimum and maximum working set limits.

IsRespondingCore ( ) : bool
OpenStream ( int fd, FileAccess access ) : FileStream

Opens a stream around the specified file descriptor and with the specified access.

ParseArgumentsIntoList ( string arguments, List results ) : void

Parses a command-line argument string into a list of arguments.

This follows the rules outlined in "Parsing C++ Command-Line Arguments" at https://msdn.microsoft.com/en-us/library/17w5ykft.aspx.

ParseArgv ( ProcessStartInfo psi ) : string[]

Converts the filename and arguments information from a ProcessStartInfo into an argv array.

RefreshCore ( ) : void

Discards any information about the associated process.

ResolvePath ( string filename ) : string

Resolves a path to the filename passed to ProcessStartInfo.

SetPrivilege ( string privilegeName, int attrib ) : void
SetWorkingSetLimitsCore ( IntPtr newMin, IntPtr newMax, IntPtr &resultingMin, IntPtr &resultingMax ) : void

Sets one or both of the minimum and maximum working set limits.

Start ( string fileName, string userName, SecureString password, string domain ) : Process
Start ( string fileName, string arguments, string userName, SecureString password, string domain ) : Process
Start ( string fileName, string userName, System password, string domain ) : System.Diagnostics.Process
Start ( string fileName, string arguments, string userName, System password, string domain ) : System.Diagnostics.Process
StartCore ( ProcessStartInfo startInfo ) : bool

Starts the process using the supplied start info.

TicksToTimeSpan ( double ticks ) : System.TimeSpan

Convert a number of "jiffies", or ticks, to a TimeSpan.

UpdateHasExited ( ) : void

Checks whether the process has exited and updates state accordingly.

WaitForExitCore ( int milliseconds ) : bool

Instructs the Process component to wait the specified number of milliseconds for the associated process to exit.

WaitForInputIdleCore ( int milliseconds ) : bool

Method Details

BeginErrorReadLine() public method

public BeginErrorReadLine ( ) : void
return void

BeginOutputReadLine() public method

public BeginOutputReadLine ( ) : void
return void

CancelErrorRead() public method

public CancelErrorRead ( ) : void
return void

CancelOutputRead() public method

public CancelOutputRead ( ) : void
return void

Close() public method

public Close ( ) : void
return void

CloseMainWindow() public method

public CloseMainWindow ( ) : bool
return bool

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

EnterDebugMode() public static method

Puts a Process component in state to interact with operating system processes that run in a special mode by enabling the native property SeDebugPrivilege on the current thread.
public static EnterDebugMode ( ) : void
return void

GetCurrentProcess() public static method

public static GetCurrentProcess ( ) : System.Diagnostics.Process
return System.Diagnostics.Process

GetProcessById() public static method

public static GetProcessById ( int processId ) : System.Diagnostics.Process
processId int
return System.Diagnostics.Process

GetProcessById() public static method

public static GetProcessById ( int processId, string machineName ) : System.Diagnostics.Process
processId int
machineName string
return System.Diagnostics.Process

GetProcesses() public static method

public static GetProcesses ( ) : System.Diagnostics.Process[]
return System.Diagnostics.Process[]

GetProcesses() public static method

public static GetProcesses ( string machineName ) : System.Diagnostics.Process[]
machineName string
return System.Diagnostics.Process[]

GetProcessesByName() public static method

Creates an array of Process components that are associated with process resources on a remote computer. These process resources share the specified process name.
public static GetProcessesByName ( string processName, string machineName ) : System.Diagnostics.Process[]
processName string
machineName string
return System.Diagnostics.Process[]

GetProcessesByName() public static method

public static GetProcessesByName ( string processName ) : System.Diagnostics.Process[]
processName string
return System.Diagnostics.Process[]

GetProcessesByName() public static method

public static GetProcessesByName ( string processName, string machineName ) : System.Diagnostics.Process[]
processName string
machineName string
return System.Diagnostics.Process[]

Kill() public method

Stops the associated process immediately.
public Kill ( ) : void
return void

LeaveDebugMode() public static method

Takes a Process component out of the state that lets it interact with operating system processes that run in a special mode.
public static LeaveDebugMode ( ) : void
return void

OnExited() protected method

protected OnExited ( ) : void
return void

Process() public method

public Process ( )

Refresh() public method

public Refresh ( ) : void
return void

Start() public static method

public static Start ( System startInfo ) : System.Diagnostics.Process
startInfo System
return System.Diagnostics.Process

Start() public static method

public static Start ( string fileName ) : System.Diagnostics.Process
fileName string
return System.Diagnostics.Process

Start() public static method

public static Start ( string fileName, string arguments ) : System.Diagnostics.Process
fileName string
arguments string
return System.Diagnostics.Process

Start() public method

public Start ( ) : bool
return bool

ToString() public method

public ToString ( ) : string
return string

WaitForExit() public method

public WaitForExit ( int milliseconds ) : bool
milliseconds int
return bool

WaitForExit() public method

public WaitForExit ( ) : void
return void

WaitForInputIdle() public method

public WaitForInputIdle ( ) : bool
return bool

WaitForInputIdle() public method

public WaitForInputIdle ( int milliseconds ) : bool
milliseconds int
return bool