/// <summary> /// Handles the DoWork event of the errorWorker control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs" /> instance containing the event data.</param> void ErrorWorker_DoWork(object sender, DoWorkEventArgs e) { while (!ErrorWorker.CancellationPending && ErrorReader is not null) { // Any lines to read? int count; var buffer = new char[1024]; do { var builder = new StringBuilder(); count = ErrorReader.Read(buffer, 0, 1024); builder.Append(buffer, 0, count); ErrorWorker.ReportProgress(0, builder.ToString()); } while (count > 0); System.Threading.Thread.Sleep(200); } }