// 验证是否需要更新 BOOL CUpdaterApp::_CheckNeedUpdate() { BOOL bReturn(FALSE); int nCount = m_arrUpdate.GetSize(); if (nCount > 0) { // 启动线程池 SYSTEM_INFO si = {0}; GetSystemInfo(&si); CThreadPool *pThreadPool = new CThreadPool(32); for (int i(0); i < nCount; ++i) { pThreadPool->Run(_CheckFileMD5, m_arrUpdate.GetAt(i)); } pThreadPool->Wait(INFINITE); delete pThreadPool; // 检查是否存在更新 BOOL bExistUpdate(FALSE); for (int j(0); j < nCount; ++j) { if (m_arrUpdate.GetAt(j)->bNeedUpdate) { bExistUpdate = TRUE; break; } } if (bExistUpdate) { // 询问控制窗口 if (IsWindow(m_hWindowCtrl)) { if (0 == SendMessage(m_hWindowCtrl, UM_IFNEEDUPDATE, 0, 0)) { // 返回值0允许更新 bReturn = TRUE; } } } } else { LOG(_T("更新列表为空!")); } return bReturn; }
UINT CServerApp::MainTh(LPVOID param) { CServerApp* app = (CServerApp*)param; // 设置线程池内线程数量 g_threadPool.SetPoolSize(20); // 创建线程 g_threadPool.Create(); while(true) { MessageQueue::ValueType msg = g_msgQueue.Pop(); //启动线程处理消息 g_threadPool.Run(CServerApp::WorkTh,msg,Low); } return 0; }