获取线程退出码
DWORD dwExitCode;
GetExitCodeThread( m_pThreadRecv->m_hThread, &dwExitCode );
AfxEndThread( dwExitCode, TRUE );
AfxEndThread只能在线程体内调用,如果外部结束要保存AfxbeginThread返回的线程指针CWinThread*,
然后调用CWinThread类的PostThreadMessage令线程退出。
开启一个线程
CWinThread *pThread;
if(pThread=AfxBeginThread(CMServer::NewThread, m_pMServer, THREAD_PRIORITY_LOWEST,
0, CREATE_SUSPENDED, NULL))
{
pThread->m_bAutoDelete=true;//设为真,就不需要你操心删除了,mfc帮你.
}