Windows Forms: Why does the output of the long-acting algorithm in the text box stop after a while?

I wrote a .NET application with a Windows Forms GUI. The application runs a long algorithm in the main thread of the graphical interface (the second thread is not created).

The algorithm logs progress information using System :: Console. System.Console is redirected to the TextBox using System.Console.SetOut ().

During the first 10-30 seconds, everything works fine, and everything is written to the TextBox. However, after a while, the TextBox freezes and does not show any additional logs - the missing logs are printed immediately after the algorithm has stopped.

Question: why does it work for a while and then stops? In my opinion, it should either work or not work.

PS: I understand that this problem is best solved using the second workflow of the algorithm and some delegates to print the log. But this is experimental code, and I'm just wondering why it works for a while and then stops.

+3
source share
2 answers

Add Application.DoEvents to a lengthy process

+1
source
  • "" Windows .
    Application.DoEvents Windows .
  • , ( , ).
+1

Source: https://habr.com/ru/post/1774913/


All Articles