public void Add(string text)
{
lock (queue.SyncRoot) {
again:
int pos = text.IndexOf ('\n');
if (pos < 0)
current_line += text;
else {
current_line += text.Substring (0, pos);
queue.Enqueue (current_line);
current_line = "";
text = text.Substring (pos + 1);
if (text.Length > 0)
goto again;
}
wait_event.Set ();
}
}