This article is a mirror article of machine translation, please click here to jump to the original article.

View: 24628|Reply: 1

[WinForm] C# task.waitall will freeze the interface

[Copy link]
Posted on 6/26/2017 10:01:09 PM | | |
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!




Previous:Verification of WebAPI Universal Signatures (2)
Next:Alibaba Cloud SMS Service sends promotional SMS messages in batches
Posted on 12/1/2022 3:02:09 PM |
I'm now having the same issue, the subthread gets stuck when it blocks with task.waitall after starting.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com