void CDlgMain::ExitPayThread() { if(m_hThread==NULL) return ; DWORD rc=WaitForSingleObject(m_hThread,1000);//等待10秒, 然后开始杀线程 if(rc==WAIT_TIMEOUT) { //强行退出工作线程 DWORD exitCode; ::GetExitCodeThread(m_hThread, &exitCode;); if ( exitCode==STILL_ACTIVE ) { try { TerminateThread(m_hThread, 0x03); CloseHandle(m_hThread);//线程对象还在内存中, 要释放 m_bProcessing=false; //m_Animation.ShowWindow(SW_HIDE); //m_Animation.Stop(); } catch(...) { AfxMessageBox("强行退出一个工作线程时发生异常"); } } } } TerminateThread(m_hThread, 0x03); CloseHandle(m_hThread);//线程对象还在内存中, 要释放 m_bProcessing=false; //m_Animation.ShowWindow(SW_HIDE); //m_Animation.Stop(); } catch(...) { AfxMessageBox("强行退出一个工作线程时发生异常"); } } } }