private void doProcess(string filename, string arguments, string workingDir, AppendLine output) { var process = Process.Start(new ProcessStartInfo { FileName = filename, Arguments = arguments, WorkingDirectory = workingDir, UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true, CreateNoWindow = true, }); process.OutputDataReceived += (sender, args) => output(string.IsNullOrEmpty(args.Data) ? "" : args.Data); process.ErrorDataReceived += (sender, args) => output(string.IsNullOrEmpty(args.Data) ? "" : args.Data); process.BeginOutputReadLine(); process.BeginErrorReadLine(); _processes.Add(process); var pids = new List <string>(); if (File.Exists(_pidsFile)) { pids = File.ReadAllLines(_pidsFile).ToList(); } pids.Add(process.Id.ToString()); File.WriteAllLines(_pidsFile, pids.ToArray()); }
private Process python(string script, AppendLine output) { var workingDir = Path.GetDirectoryName(script); Environment.SetEnvironmentVariable("PYTHONHOME", _pythonDir); var filename = Path.Combine(_pythonDir, "python.exe"); return(doProcess(filename, $"\"{script}\"", workingDir, output)); }
private Process exec(string exe, AppendLine output) { var workingDir = Path.GetDirectoryName(exe); return(doProcess(exe, "", workingDir, output)); }
private void exec(string exe, AppendLine output) { var workingDir = Path.GetDirectoryName(exe); doProcess(exe, "", workingDir, output); }