I wrote a .NET application with a Windows Forms GUI. The application starts a long running algorithm in the main GUI thread (no second thread is created).
The algorithm logs progress information using System::Console.
The System.Console is redirected to a TextBox using System.Console.SetOut().
For the first 10-30 seconds everything works fine and everything is logged to the TextBox. However, after a while the TextBox freezes and does not show any further logs – the missing logs a printed all at once after the algorithm has stopped.
The question is: why is this working for some time and then stops? In my understanding it should either work or work not.
P.S.: I understand that this kind of problem is best solved using second worker thread of the algorithm and some delegates to print out the log. But it is experimental code and I am just curious why it works for some time and then stops.
Add an Application.DoEvents in the long-running process