12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
-
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- namespace OpenSim.GridLaunch
- {
- internal partial class AppExecutor
- {
-
- #region Start / Stop timer thread
- private void timer_Start()
- {
- asyncReadOutput();
- asyncReadError();
- }
- private bool running = true;
- private void timer_Stop()
- {
- running = false;
- }
- #endregion
- private byte[] readBufferOutput = new byte[4096];
- private byte[] readBufferError = new byte[4096];
- private void asyncReadOutput()
- {
- if (running)
- Output.BaseStream.BeginRead(readBufferOutput, 0, readBufferOutput.Length, asyncReadCallBackOutput, null);
- }
- private void asyncReadError()
- {
- if (running)
- Error.BaseStream.BeginRead(readBufferError, 0, readBufferError.Length, asyncReadCallBackError, null);
- }
- private void asyncReadCallBackOutput(IAsyncResult ar)
- {
- int len = Output.BaseStream.EndRead(ar);
- Program.FireAppConsoleOutput(file,
- System.Text.Encoding.ASCII.GetString(readBufferOutput, 0, len)
- );
- asyncReadOutput();
- }
- private void asyncReadCallBackError(IAsyncResult ar)
- {
- int len = Error.BaseStream.EndRead(ar);
- Program.FireAppConsoleError(file,
- System.Text.Encoding.ASCII.GetString(readBufferError, 0, len)
- );
- asyncReadError();
- }
- }
- }
|