-
MFC Bug or My Bug
I've written a very simple MFC Dialog Program
A dialog contain a OK Button and a edit control
then i write the following code
UINT TestThread(LPVOID lpParam)
{
CSocket s;
s.Create(0,SOCK_DGRAM);
while (1) {
//...
Sleep(1000);
}
}
void CTestDialog::OnOK()
{
AfxSocketInit(NULL);
AfxBeginThread(TestThread,0);
}
when the thread start, all things seems well, but when i want to shift another input method in the edit box, the mainthread is hang~
What's the problem in my code .
Any advice will be appreciate
-
Re: MFC Bug or My Bug
Call the AfxInitSocket() function only once in your CWinApp::InitInstance.
-
Re: MFC Bug or My Bug
Also specify the lpszSockAddress (third parameter in Create function) as a pointer to a string containing the network address of the connected socket.
-
Re: MFC Bug or My Bug
thanks amarcode, but i've try your way before, and the error still~
when i Replace all the CSocket Function with SOCKET function , the whole scenario work very well.
but it really a problem that confused me for 2 days . :(
i think the core thing is:
when i use a MFC Class with MessageQueue in a Thread, Something happen but i do not know.
any new advice?
-
Re: MFC Bug or My Bug