/// <summary> /// Run an executable. Will wait for up to <c>ProcessTimeout</c> time, /// then kill the process. Will retry up to 3 times if the timeout is reached. /// </summary> /// <param name="processRunner"> /// The process runner. /// </param> /// <param name="arguments"> /// The arguments. /// </param> /// <param name="workingDirectory"> /// The working Directory. /// </param> protected void RunExe(ProcessRunner processRunner, string arguments, string workingDirectory) { // set ProcessRunner to have a timeout and retry processRunner.WaitForExitMilliseconds = Convert.ToInt32(this.ProcessRunnerTimeout.TotalMilliseconds); processRunner.MaxRetries = this.ProcessRunnerMaxRetries; processRunner.WaitForExit = true; if (this.Log.IsDebugEnabled) { var stopwatch = new Stopwatch(); stopwatch.Start(); processRunner.Run(arguments, workingDirectory); stopwatch.Stop(); this.Log.DebugFormat( "Executed {0} in working directory {1}. Took {2} ({3}ms). Exit code: {4}", processRunner.ExecutableFile.Name, workingDirectory, stopwatch.Elapsed.Humanise(), stopwatch.Elapsed.TotalMilliseconds, processRunner.ExitCode); this.Log.Verbose(processRunner.BuildLogOutput()); } else { processRunner.Run(arguments, workingDirectory); } if (processRunner.ExitCode != 0) { throw new AudioUtilityException($"Failed to execute process: exit code was `{processRunner.ExitCode}`. `{processRunner.ExecutableFile}` `{arguments}`"); } if (this.Log.IsWarnEnabled) { var failedRunOutput = processRunner.FailedRunOutput; if (failedRunOutput.Any()) { foreach (var failure in failedRunOutput) { this.Log.Warn(failure); } } } }