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