Пример #1
0
		private static void WireUpTheOutputOfTheReplProcessToTheTextBox(TextBox replTextBox, Process replProcess, Entity<ReplState> replEntity)
		{
			var standardOutputStream = new StreamBuffer();
			var standardErrorStream = new StreamBuffer();
			var processOutputReader = new ProcessOutputReader(new TextBoxWriter(replTextBox, replEntity), standardOutputStream, standardErrorStream);
			var outputReaderThread = new Thread(processOutputReader.StartMarshallingTextFromReplToTextBox);
			var outputBufferStreamThread = new Thread(() => standardOutputStream.ReadStream(replProcess.StandardOutput.BaseStream));
			var errorBufferStreamThread = new Thread(() => standardOutputStream.ReadStream(replProcess.StandardError.BaseStream));

			replTextBox.Loaded +=
				(o, e) =>
				{
					if (outputReaderThread.IsAlive) return;
					replProcess.Start();
					replProcess.StandardInput.AutoFlush = true;
					outputBufferStreamThread.Start();
					errorBufferStreamThread.Start();
					outputReaderThread.Start();
				};

			replProcess.Exited +=
				(o, e) =>
				{
					outputBufferStreamThread.Abort();
					errorBufferStreamThread.Abort();
					outputReaderThread.Abort();
				};
		}
Пример #2
0
		public ProcessOutputReader(TextBoxWriter textBoxWriter, StreamBuffer outputStreamBuffer, StreamBuffer errorStreamBuffer)
		{
			_textBoxWriter = textBoxWriter;
			_outputStreamBuffer = outputStreamBuffer;
			_errorStreamBuffer = errorStreamBuffer;
		}