public AsyncProcess Exec(string cmdline, string workingDirectory, IDictionary environment) { return(AsyncProcess.Start(new ProcessStartInfo { FileName = Path, WorkingDirectory = workingDirectory, }, environment)); }
public AsyncProcess Exec(string cmdline, string workingDirectory) { return(AsyncProcess.Start(new ProcessStartInfo { FileName = Path, WorkingDirectory = workingDirectory, })); }
public static AsyncProcess Start(ProcessStartInfo startInfo, IDictionary environment) { startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; if (environment != null) { foreach (var i in environment.Keys) { startInfo.EnvironmentVariables[(string)i] = (string)environment[i]; } } var result = new AsyncProcess(new Process { StartInfo = startInfo }); result._process.EnableRaisingEvents = true; // set up std* access result._process.ErrorDataReceived += (sender, args) => { result._stdError.Add(args.Data ?? string.Empty); }; result._process.OutputDataReceived += (sender, args) => { result._stdOut.Add(args.Data ?? string.Empty); }; result._process.Exited += (sender, args) => { result.WaitForExit(); result._stdError.Completed(); result._stdOut.Completed(); }; result._process.Start(); result._process.BeginErrorReadLine(); result._process.BeginOutputReadLine(); return(result); }
public AsyncProcess Exec(string cmdline, IDictionary environment) { return(AsyncProcess.Start(Path, cmdline, environment)); }
public AsyncProcess Exec(IDictionary environment) { return(AsyncProcess.Start(Path, environment)); }
public AsyncProcess Exec(string cmdline) { return(AsyncProcess.Start(Path, cmdline)); }
public AsyncProcess Exec() { return(AsyncProcess.Start(Path)); }
public static AsyncProcess Start(ProcessStartInfo startInfo, IDictionary environment) { startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; if (environment != null) { foreach (var i in environment.Keys) { startInfo.EnvironmentVariables[(string)i] = (string)environment[i]; } } var process = new Process { StartInfo = startInfo }; var result =new AsyncProcess(process); process.EnableRaisingEvents = true; // set up std* access process.ErrorDataReceived += (sender, args) => result._stdError.Add(args.Data); process.OutputDataReceived += (sender, args) => result._stdOut.Add(args.Data); process.Exited +=(sender, args) => { result._stdError.Completed(); result._stdOut.Completed(); }; process.Start(); process.BeginErrorReadLine(); process.BeginOutputReadLine(); return result; }