예제 #1
0
        private void Launch(string rBasePath, string executable, string arguments)
        {
            string binPath = RInstallation.GetBinariesFolder(rBasePath, new SupportedRVersionRange());

            if (!string.IsNullOrEmpty(binPath))
            {
                ProcessStartInfo info = new ProcessStartInfo();

                info.FileName               = Path.Combine(binPath, executable);
                info.Arguments              = arguments;
                info.UseShellExecute        = false;
                info.RedirectStandardOutput = true;
                info.RedirectStandardError  = true;
                info.CreateNoWindow         = true;
                info.WindowStyle            = ProcessWindowStyle.Hidden;

                _rProcess           = new Process();
                _rProcess.StartInfo = info;

                _rProcess.Exited             += OnProcessExited;
                _rProcess.OutputDataReceived += OnOutputDataReceived;
                _rProcess.ErrorDataReceived  += OnErrorDataReceived;

                _rProcess.Start();

                _rProcess.BeginOutputReadLine();
                _rProcess.BeginErrorReadLine();

                _rProcess.WaitForExit();

                Dispose();
            }
        }