public void WriteNewData(string value)
{
if (string.IsNullOrEmpty(value))
return;
int idx;
while ((idx = value.IndexOfAny(new char[] { '\n', '\r' })) > -1)
{
string lineData = buffer.ToString() + value.Substring(0, idx);
buffer.Clear();
idx++;
while (idx < value.Length)
{
if (value[idx] == '\n' || value[idx] == '\r')
idx++;
else
break;
}
value = value.Substring(idx);
if (!string.IsNullOrEmpty(lineData))
RaiseLineReceived(lineData);
}
if (!string.IsNullOrEmpty(value))
buffer.Append(value);
}