示例#1
0
        public XProcess(ProcessStartInfo startInfo, XProcessOptions options)
        {
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;

            this.Options = options;

            this.OutputChannel = Channel.CreateUnbounded <XProcessOutputFragment>(new UnboundedChannelOptions
            {
                SingleReader = false,
                SingleWriter = true,
                AllowSynchronousContinuations = true
            });

            this.Process = new Process
            {
                StartInfo           = startInfo,
                EnableRaisingEvents = true
            };
            this.Process.Exited             += Process_Exited;
            this.Process.OutputDataReceived += Process_OutputDataReceived;
            this.Process.ErrorDataReceived  += Process_ErrorDataReceived;

            this.Process.Start();
            this.Process.BeginOutputReadLine();
            this.Process.BeginErrorReadLine();
        }
示例#2
0
        public static XProcess Start(ProcessStartInfo startInfo, Action <XProcessOptions>?configure = null)
        {
            var options = new XProcessOptions();

            configure?.Invoke(options);
            return(new XProcess(startInfo, options));
        }
示例#3
0
        public static XProcess Start(string?filename, string?arguments = "", string?workingDirectory = "", Action <XProcessOptions>?configure = null)
        {
            var options = new XProcessOptions();

            configure?.Invoke(options);
            return(new XProcess(filename, arguments, workingDirectory, options));
        }
示例#4
0
 public XProcess(string?filename, string?arguments, string?workingDirectory, XProcessOptions options)
     : this(new ProcessStartInfo
 {
     FileName = filename,
     Arguments = arguments,
     WorkingDirectory = workingDirectory
 }, options)
 {
 }