Home > Back-end > Used in the thread of the ActiveX socket, switch input method crashing
Used in the thread of the ActiveX socket, switch input method crashing
Time:10-11
Basic program structure: first established the socket in the ActiveX (block), a new thread after the connection is successful, the thread with recv (blocking mode) to receive data from the other (do - while mode, circulation has been waiting for death, after the test, the thread of the pure cycle will not result in the death of input switch card dead, once a socket is involved in will stuck), socket and thread processing are standard winapi way, not MFC, Problem: waiting for recv when receiving data, IE the page in a input box casually focal switch input method, will be stuck (sogou, Microsoft, such as QQ input method will be jammed), online information is new thread + socket mode switch, there is no message loop to deal with input caused sendmessage jammed, so need to destroy the IME window, but the solution also have never thought, comment,
CodePudding user response:
Infinite loop with a little delay, Message processing or application
CodePudding user response:
Infinite loop plus time delay is Sleep? This tried or jammed, as for message processing to add in where? The thread function in the body? Still? Thank you,
CodePudding user response:
Not have a solution? Kill the ime window is good Void __fastcall TDBThread: : FreeIMEWindow () { //if GetCurrentThreadId=the main thread IDthen exit;//if it is the main thread, it should have a message loop, can not handle HWND h=FindWindow (" the IME ", "Default IME"); DWORD pid; HWND dh.
While (IsWindow (h)) { If (GetWindowThreadProcessId (h, & amp; Pid)==GetCurrentThreadId ()) { Dh=h; } The else Dh=NULL; H=FindWindowEx (0, h, "the IME", "Default IME"); If (dh) The DestroyWindow (dh); } }
CodePudding user response:
Have, in accordance with the above scheme tried but seems not, debugging, and add a messagebox line of code If (GetWindowThreadProcessId (h, & amp; Pid)==GetCurrentThreadId ()) { MessageBox (0, cstrings (" found!" ), cstrings (" 0 "), 0); Dh=h; } But doesn't show this messagebox, also is to show that no and thread corresponding to the IME window, this is very strange ~
In addition, make sure my process, because I am a novice, so also please the great god to see if the process has a problem: 1, creating the socket links in the main thread, thread (m_ThreadHandle=CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) RecvData, this, 0, & amp; M_ThreadID); 2, RecvData function call the above method in the destruction of the thread their own IME Windows Void RecvData (XXXX) { FreeIMEWindows ();//the above treatment methods
//infinite loop to wait for the other party to send data, using recv blocking mode }
Hope the great god directions, the problem didn't solve for a long time, depressed ~