结束线程的处理方法:
SetEvent(hRequestExitEvent);
int nCount = vctr_sWebCheck.size();
HANDLE* arrayThread = new HANDLE[nCount];
for (size_t i = 0; i < nCount ; ++i)
{
arrayThread[i] = vctr_hWinThread[i]->m_hThread;
}
TRACE(_T("success initialed"));
WaitForMultipleObjects(nCount, arrayThread, TRUE, INFINITE);
for (int n = 0; n < nCount; ++n)
{
CloseHandle(arrayThread[n]);
}
delete []arrayThread;
ResetEvent(hRequestExitEvent);
SetEvent(hRequestExitEvent);
int nCount = vctr_sWebCheck.size();
HANDLE* arrayThread = new HANDLE[nCount];
for (size_t i = 0; i < nCount ; ++i)
{
arrayThread[i] = vctr_hWinThread[i]->m_hThread;
}
TRACE(_T("success initialed"));
WaitForMultipleObjects(nCount, arrayThread, TRUE, INFINITE);
for (int n = 0; n < nCount; ++n)
{
CloseHandle(arrayThread[n]);
}
delete []arrayThread;
ResetEvent(hRequestExitEvent);
注意 ResetEvent(hRequestExitEvent);
vctr_hWinThread.clear();
hRequestExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
OnGetCheckWebInfo(0, 0);
size_t nCount = vctr_sWebCheck.size();
for (size_t i = 0; i < nCount; ++i)
{
// hWebCheckWnd = this->m_hWnd;
vctr_hWinThread.push_back(AfxBeginThread(McThreadCheckWeb, &vctr_sWebCheck[i])) ;
}
注意初始化:hRequestExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
OnGetCheckWebInfo(0, 0);
size_t nCount = vctr_sWebCheck.size();
for (size_t i = 0; i < nCount; ++i)
{
// hWebCheckWnd = this->m_hWnd;
vctr_hWinThread.push_back(AfxBeginThread(McThreadCheckWeb, &vctr_sWebCheck[i])) ;
}
hRequestExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);