示例#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
		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();
				};
		}