System.Diagnostics.Process.ProcessAsyncReader.Flush C# (CSharp) Method

Flush() public method

public Flush ( bool last ) : void
last bool
return void
			void Flush (bool last)
			{
				if (sb.Length == 0 ||
				    (err_out && process.output_canceled) ||
				    (!err_out && process.error_canceled))
					return;

				string total = sb.ToString ();
				sb.Length = 0;
				string [] strs = total.Split ('\n');
				int len = strs.Length;
				if (len == 0)
					return;

				for (int i = 0; i < len - 1; i++) {
					if (err_out)
						process.OnOutputDataReceived (strs [i]);
					else
						process.OnErrorDataReceived (strs [i]);
				}

				string end = strs [len - 1];
				if (last || (len == 1 && end == "")) {
					if (err_out) {
						process.OnOutputDataReceived (end);
					} else {
						process.OnErrorDataReceived (end);
					}
				} else {
					sb.Append (end);
				}
			}