The recently written Program has a small problem. MessageBox is used in a certain place. If you click OK quickly, the whole program will not respond. because it is not a crash, it is considered a deadlock. later I used log and found the problem. Let's take a look at Log File: Time at: 0004234132 line: 0 adddownloadtaskready enter criticaltime at: 0004234194 line: 1 adddownloadtaskready leave criticaltime at: 0004234803 line: export ready enter criticaltime at: 0004234803 line: 3_fddownloadresultcallbackinclass enter criticaltime at: 0004236207/* message box ("here"); */line: 4 adddownloadtaskready enter criticaltime at: 0004243398 line: 5 call downloadresult js fn/* sendmessage (...); */
We can see that after line: 4, adddownloadtask has not entered critical, but has been waiting. because adddownloadtask is a function called by the main thread, it has been waiting for _ fddownloadresultcallbackinclass to exit critical, but _ fddownloadresultcallbackinclass is displaying MessageBox, so the main thread is blocked! After clicking OK MessageBox, The _ fddownloadresultcallbackinclass executes the last step to send a message, but the main thread is still blocked at this time, so the sendmessage remains waiting for the main thread to return sendmessage, so everyone will continue to consume it. to put it simply: 1. enter critical, pending, 2. at this time, other functions will enter critical, wait, and cause the main thread to Block 3. 1. After Entering critical, after a period of suspension, the suspension is lifted. sendmessage (note not postmessage) 4. because the main thread is blocked, sendmessage cannot be sent, and 1 cannot exit critical5. overall blocking.