public PowerShellAgentRunner(AgentRequest request, string workingDirectory, TimeSpan timeout, ClrVersion clrVersion) { _outputBuilder = new SynchronizedStringBuilder(new StringBuilder(0x1000)); _request = request; _workingDirectory = workingDirectory; _timeout = timeout; _clrVersion = clrVersion; }
public AsyncProcessOutputAndErrorReader(Process process, SynchronizedStringBuilder combinedOutput) { _combinedOutput = combinedOutput; _threads = new[] { new Thread(() => CopyReaderToOutput(process.StandardOutput, _combinedOutput)), new Thread(() => CopyReaderToOutput(process.StandardError, _combinedOutput)) }; }
private void CopyReaderToOutput(TextReader reader, SynchronizedStringBuilder outputBuilder) { const int bufferSize = 100; var buffer = new char[bufferSize]; int charsRead; do { charsRead = reader.Read(buffer, 0, buffer.Length); outputBuilder.Append(buffer, 0, charsRead); } while (charsRead > 0); }