Class ProcessService
Defines a service for running external processes with support for cancellation and timeouts.
Inherited Members
Namespace: Coree.NETStandard.Services.Process
Assembly: Coree.NETStandard.dll
Syntax
public class ProcessService : DependencySingleton<ProcessService>, IProcessService, IDependencySingleton
Constructors
| <<<<<<< HEAD Edit this page View Source ======= Edit this page View Source >>>>>>> releaseProcessService(ILogger<ProcessService>, IConfiguration)
Initializes a new instance of the ProcessService class with the specified logger and configuration.
Declaration
public ProcessService(ILogger<ProcessService> logger, IConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
ILogger<ProcessService> | logger | The logger instance for logging messages. |
IConfiguration | configuration | The configuration instance for accessing application settings. |
Methods
| <<<<<<< HEAD Edit this page View Source ======= Edit this page View Source >>>>>>> releaseRunProcessWithCancellationSupportAsync(string, string, string, bool, CancellationToken, TimeSpan?)
Runs an external process asynchronously with options for cancellation and timeout.
Declaration
public Task<ProcessRunResult> RunProcessWithCancellationSupportAsync(string fileName, string arguments, string workingDirectory, bool killOnCancel = false, CancellationToken cancellationWaitRequest = default, TimeSpan? timeout = null)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The name of the executable to run. |
string | arguments | The arguments to pass to the executable. |
string | workingDirectory | The working directory for the process. |
bool | killOnCancel | Indicates whether the process should be killed if a cancellation is requested. |
CancellationToken | cancellationWaitRequest | The cancellation token that can be used to request cancellation of the operation. |
TimeSpan? | timeout | Optional timeout after which the process will be killed if not completed. |
Returns
Type | Description |
---|---|
Task<ProcessRunResult> | A task that represents the asynchronous operation, containing the result of the process execution. |