示例#1
0
        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());
        }
示例#2
0
 public static IProcessResult StartAndWaitForExit(this ProcessArguments processArguments)
 {
     using var instance = processArguments.Start();
     return(instance.WaitForExit());
 }
示例#3
0
 public static async Task <IProcessResult> StartAndWaitForExitAsync(this ProcessArguments processArguments, CancellationToken cancellationToken = default)
 {
     using var instance = processArguments.Start();
     return(await instance.WaitForExitAsync(cancellationToken));
 }