The previous implementation of ProcessWrapper OutputStreamChanged and ErrorStreamChanged would manually launch a background thread to read on the process StandardOutput and StandardError, then simply passing the output to the OutputStreamChanged and ErrorStreamChanged events. This mean that even the newline characters would be passed to these events, leaving these events callbacks deal with splitting the output line by line.
On the other hand, Process.OutputDataReceived and Process.ErrorDataReceived already split the data line by line, and discard the newline character. That implies that, to keep the old ProcessWrapper behaviour, we need to add these newlines character before calling OutputStreamChanged and ErrorStreamChanged events callbacks.
} else {
ProcessEventHandler handler = OutputStreamChanged;
if (handler != null)
- handler (this, args.Data);
+ handler (this, args.Data + Environment.NewLine);
}
};
} else {
ProcessEventHandler handler = ErrorStreamChanged;
if (handler != null)
- handler (this, args.Data);
+ handler (this, args.Data + Environment.NewLine);
}
};