예제 #1
0
 public AsyncProcess Exec(string cmdline, string workingDirectory, IDictionary environment)
 {
     return(AsyncProcess.Start(new ProcessStartInfo {
         FileName = Path,
         WorkingDirectory = workingDirectory,
     }, environment));
 }
예제 #2
0
 public AsyncProcess Exec(string cmdline, string workingDirectory)
 {
     return(AsyncProcess.Start(new ProcessStartInfo {
         FileName = Path,
         WorkingDirectory = workingDirectory,
     }));
 }
예제 #3
0
        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);
        }
예제 #4
0
 public AsyncProcess Exec(string cmdline, IDictionary environment)
 {
     return(AsyncProcess.Start(Path, cmdline, environment));
 }
예제 #5
0
 public AsyncProcess Exec(IDictionary environment)
 {
     return(AsyncProcess.Start(Path, environment));
 }
예제 #6
0
 public AsyncProcess Exec(string cmdline)
 {
     return(AsyncProcess.Start(Path, cmdline));
 }
예제 #7
0
 public AsyncProcess Exec()
 {
     return(AsyncProcess.Start(Path));
 }
예제 #8
0
        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;
        }