Exemple #1
0
        private void CreateProccess(IProcessProxy processProxy, string binaryPath, string arguments)
        {
            var processStartInfo = new ProcessStartInfo
            {
                FileName               = binaryPath,
                Arguments              = arguments,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                CreateNoWindow         = true
            };

            try
            {
                this.process = processProxy.Start(processStartInfo);

                if (this.process != null)
                {
                    this.process.OutputDataReceived += this.ProcessOutputDataReceived;
                    this.process.BeginOutputReadLine();
                }
                else
                {
                    throw new NullReferenceException("IProcessProxy produced null object");
                }
            }
            catch (Exception ex)
            {
                throw new AggregateException(string.Format("Failed to run process '{0}' with arguments '{1}'", binaryPath, arguments), new[] { ex });
            }
        }