internal void Start() { this.processOutput = new ObjectStream(0x80); lock (this.readerLock) { if (this.redirectOutput) { this.readerCount++; this.outputReader = new ProcessStreamReader(this.process.StandardOutput, this.processPath, true, this.processOutput.ObjectWriter, this); this.outputReader.Start(); } if (this.redirectError) { this.readerCount++; this.errorReader = new ProcessStreamReader(this.process.StandardError, this.processPath, false, this.processOutput.ObjectWriter, this); this.errorReader.Start(); } } }
internal void Start() { this.processOutput = new ObjectStream(0x80); lock (this.readerLock) { if (this.redirectOutput) { this.readerCount++; this.outputReader = new ProcessStreamReader(this.process.StandardOutput, this.processPath, true, this.processOutput.ObjectWriter, this); this.outputReader.Start(); } if (this.redirectError) { this.readerCount++; this.errorReader = new ProcessStreamReader(this.process.StandardError, this.processPath, false, this.processOutput.ObjectWriter, this); this.errorReader.Start(); } } }
/// <summary> /// Start reading the output/error. Note all the work is done asynchronously. /// </summary> internal void Start() { _processOutput = new ObjectStream(128); // Start async reading of error and output // readercount variable is used by multiple threads to close "processOutput" ObjectStream. // Without properly initializing the readercount, the ObjectStream might get // closed early. readerCount is protected here by using the lock. lock (_readerLock) { if (_redirectOutput) { _readerCount++; _outputReader = new ProcessStreamReader(_process.StandardOutput, _processPath, true, _processOutput.ObjectWriter, this); _outputReader.Start(); } if (_redirectError) { _readerCount++; _errorReader = new ProcessStreamReader(_process.StandardError, _processPath, false, _processOutput.ObjectWriter, this); _errorReader.Start(); } } }