Interface IProcessControlWrapper
Wraps common Process functions.
Namespace: LemonEdge.Tools.ProcessUtilities
Assembly: LemonEdge.Tools.ProcessUtilities.dll
Syntax
public interface IProcessControlWrapper
Methods
AddArgument(ProcessStartInfo, string)
Adds an argument to a ProcessStartInfo.
Declaration
void AddArgument(ProcessStartInfo processStartInfo, string argument)
Parameters
Type | Name | Description |
---|---|---|
ProcessStartInfo | processStartInfo | |
string | argument |
CreateProcess(string)
Creates a ProcessStartInfo for the given exe path
Declaration
ProcessStartInfo CreateProcess(string exePath)
Parameters
Type | Name | Description |
---|---|---|
string | exePath |
Returns
Type | Description |
---|---|
ProcessStartInfo |
GetProcessById(int)
Returns a Process for the given process ID
Declaration
Process GetProcessById(int processId)
Parameters
Type | Name | Description |
---|---|---|
int | processId |
Returns
Type | Description |
---|---|
Process |
GetProcessesIdByName(string)
Gets the process ID by the specified process name.
Declaration
int GetProcessesIdByName(string processName)
Parameters
Type | Name | Description |
---|---|---|
string | processName | The name of the process for which to retrieve the ID. |
Returns
Type | Description |
---|---|
int | The process ID if found; otherwise, a default value (-1). |
Kill(Process)
Kills a process.
Declaration
void Kill(Process process)
Parameters
Type | Name | Description |
---|---|---|
Process | process | The process |
SetUseShellExecute(ProcessStartInfo, bool)
Sets the UseShellExecute property on a ProcessStartInfo
Declaration
void SetUseShellExecute(ProcessStartInfo processStartInfo, bool useShellExecute)
Parameters
Type | Name | Description |
---|---|---|
ProcessStartInfo | processStartInfo | |
bool | useShellExecute | Whether to use ShellExecute |
SetWorkingDirectory(ProcessStartInfo, string)
Sets the working dir of a ProcessStartInfo.
Declaration
void SetWorkingDirectory(ProcessStartInfo processStartInfo, string path)
Parameters
Type | Name | Description |
---|---|---|
ProcessStartInfo | processStartInfo | |
string | path |
Start(ProcessStartInfo)
Starts a given process for the provided ProcessStartInfo
Declaration
Process Start(ProcessStartInfo processStartInfo)
Parameters
Type | Name | Description |
---|---|---|
ProcessStartInfo | processStartInfo |
Returns
Type | Description |
---|---|
Process |
WaitForExitAsync(Process, CancellationToken)
Waits for a process to exit.
Declaration
Task WaitForExitAsync(Process process, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Process | process | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |