BOOL Terminate_Thread( CWinThread * pCWinThread )
{
DWORD dwExitCode = 0;
::GetExitCodeThread( pCWinThread->m_hThread, &dwExitCode );
//这两个函数直接写到线程中,就相当于return,工作者线程隐含调用了ExitThread;
//::ExitThread( dwExitCode ); //结束当前线程;
//AfxEndThread( dwExitCode );//结束当前线程;还容易崩溃;
return TerminateThread( pCWinThread->m_hThread, dwExitCode );//强制结束指定线程;
}
虽然有很多人在网上不建议TerminateThread结束线程,不过在有些时候还是很有用处的;