2011年9月6日 星期二

WaitForMultipleObjects

 CClassView* pThis = (CClassView*) param;
pThis->m_bReadDone = false;
pThis->m_wndNodeCtrl.m_vctFileInfo.clear();
pThis->m_wndNodeCtrl.m_strEventInfo.clear();

HANDLE handles[2];
CWinThread * pThread[2];
pThread[0] = AfxBeginThread(thdReadDirectory,pThis);
pThread[1] = AfxBeginThread(CFileTreeList::thdGetEventFromDB, &(pThis->m_wndNodeCtrl));

for(int i=0;i<2;i++)
{
handles[i] = pThread[i]->m_hThread;
pThread[i]->m_bAutoDelete = false;
}

DWORD nRet = ::WaitForMultipleObjects(2, handles, true, INFINITE);
if(nRet == WAIT_OBJECT_0 )
{
pThis->m_wndNodeCtrl.vMatchEvent();
if(pThis->m_wndNodeCtrl.m_bEvent == true)
{
pThis->OnSelChangeDateCbobox();
pThis->m_wndNodeCtrl.UpdateWindow();
}
}
pThis->m_bReadDone = true;

delete pThread[0];
delete pThread[1];

    return 0;

沒有留言:

張貼留言