public void RunAsync(
string toolPath, string arguments,
CommandLine.CompletionHandler completionDelegate,
string workingDirectory = null, Dictionary<string, string> envVars = null,
CommandLine.IOHandler ioHandler = null, int maxProgressLines = 0)
{
CommandLineDialog.ProgressReporter reporter = new CommandLineDialog.ProgressReporter();
reporter.maxProgressLines = maxProgressLines;
// Call the reporter from the UI thread from this window.
UpdateEvent += reporter.Update;
// Connect the user's delegate to the reporter's completion method.
reporter.Complete += completionDelegate;
// Connect the caller's IoHandler delegate to the reporter.
reporter.DataHandler += ioHandler;
// Disconnect the reporter when the command completes.
CommandLine.CompletionHandler reporterUpdateDisable =
(CommandLine.Result unusedResult) => { this.UpdateEvent -= reporter.Update; };
reporter.Complete += reporterUpdateDisable;
CommandLine.RunAsync(toolPath, arguments, reporter.CommandLineToolCompletion,
workingDirectory: workingDirectory, envVars: envVars,
ioHandler: reporter.AggregateLine);
}