I wrote a program today and found that the winform interface is stuck and not unresponsive, However, clicking on the software, there is no reflection at all, and it has entered a state of suspended animation.
Then, debugging, no exceptions were thrown, what is the problem?
Because you wrote this sentence in the main thread, this makes the main thread wait for all the tasks to be executed before executing the following code I also encountered this problem, opening a new child thread in the main thread, but waiting for all the child threads to complete the execution before running the next code of the main thread, using the wait method will freeze the interface Seeing the comments on the Internet, I suddenly realized, I put
It is written in the main thread, which has been waiting for all tasks to end, resulting in the interface entering a state of suspended animation
The solution is as follows:
Wrap a thread outside Thread, solve!
|