public static IProcessInstance Start(ProcessStartInfo startInfo, EventHandler <string>?outputHandler, EventHandler <string>?errorHandler) { var arguments = new ProcessArguments(startInfo); if (outputHandler != default) { arguments.OutputDataReceived += outputHandler; } if (errorHandler != default) { arguments.ErrorDataReceived += errorHandler; } return(arguments.Start()); }
public static IProcessResult StartAndWaitForExit(this ProcessArguments processArguments) { using var instance = processArguments.Start(); return(instance.WaitForExit()); }
public static async Task <IProcessResult> StartAndWaitForExitAsync(this ProcessArguments processArguments, CancellationToken cancellationToken = default) { using var instance = processArguments.Start(); return(await instance.WaitForExitAsync(cancellationToken)); }