/// <summary> /// Reads a <see cref="ConsoleStream{T}" /> until <see cref="ConsoleStream{T}.IsFinished" /> is set to true /// or a timeout occured on a read. /// </summary> /// <typeparam name="T">The type of returned items in the console stream.</typeparam> /// <param name="stream">The stream to read from.</param> /// <param name="millisTimeout"> /// The amount of time to wait on a single <see cref="ConsoleStream{T}.TryRead" /> before returning. /// </param> /// <returns>A list of items read from the console stream.</returns> public static IList <T> ReadToEnd <T>(this ConsoleStream <T> stream, int millisTimeout = 5000) where T : class { var list = new List <T>(); while (!stream.IsFinished) { var line = stream.TryRead(millisTimeout); if (null == line) { break; } list.Add(line); } return(list); }