L
L
LittleBob2022-02-20 22:54:32
C++ / C#
LittleBob, 2022-02-20 22:54:32

How to remove WinForms hang during loop execution?

A simple application with one button. After the button is clicked, a method is called that runs the loop indefinitely. And during the execution of the cycle, the application can no longer be used, it freezes. But when the cycle ends, everything is fine.
How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Ternick, 2022-02-20
@LittleBob

You need to use streams.
Loops, execution of other complex functions inside the gui thread causes the program to hang and crash due to the blocking of the main application thread, as a result of which the program cannot process other events.
Examples:
https://docs.microsoft.com/en-us/dotnet/api/system...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question