public string ReadLine() { while (true) { var line = output.Pop(1, null); if (line != null) { return(line); } if (disposed) { return(null); } } }
public void WaitFor(int toms, string format, params object[] args) { var dl = DateTime.Now.AddMilliseconds(toms); var pattern = TextTools.Format(format, args); while (true) { //Logger.Trace("POPPING for {0}", pattern); var line = input.Pop(1, null); //if (line == null) Logger.Trace("POP <NULL>"); //if (line != null) Logger.Trace("POP {0}", line); //Beware | is regex reserved `or` if (line != null && Regex.IsMatch(line, pattern)) { break; } //if (DateTime.Now > dl) Logger.Trace("Timeout waiting for `{0}`", TextTools.Readable(pattern)); if (DateTime.Now > dl) { throw ExceptionTools.Make("Timeout waiting for `{0}`", TextTools.Readable(pattern)); } } }