I create a worker thread, in a worker thread set a timer timer, responsible for timing the main dialog interface according to the data list, refresh before a global mteux locked in guard_lock, avoid conflict data access, some of the main interface message in response to the data processing, so also should be locked before processing, Now the problem is that if the news of the main interface response locked repeatedly, the program will get stuck no response, I don't know is a deadlock or what's the matter, such as locked in the double-click the message response, if repeated double-click will soon jammed in a row, or delete data in a row, before deleting locked, sometimes jammed, help to analysis what problem
CodePudding user response:
You can try this: the worker thread to get the data, filling a custom structure, then PostMessage messages to the UI thread, the UI thread received after data processing, after the completion of the processing inform worker threads execute the next operation,
Pseudo code like the following:
UINT __cdecl ThreadProc (... ) { . MSG MSG. while(! BExitThread & amp; & GetMessage (& amp; MSG, NULL, 0, 0, 0) { The switch (MSG) message) { Case MSG_XXX: { //perform calculations, filling structure data, send a custom message to inform the UI thread, } } } . }
LRESULT OnXXXXX (WPARAM, LPARAM)//UI thread custom message handler { //parse the data, UI updates PostThreadMessage (... );//notice threads to execute the next operation }