1.创建进程: ::AfxBeginThread(BkThreadProc, this->GetSafeHwnd()); 2.后台进程函数和控制线程暂停/恢复/退出的事件变量: CEvent g_EventThreadPause(FALSE,TRUE); UINT BkThreadProc(LPVOID pParam) //Check whether the backgound thread need to quit //Clean resource before quiting background thread //Check whether the backgound thread need to pause ::WaitForSingleObject(g_EventThreadPause, INFINITE); //....... //Do some background work here...... //....... //Sleep(2000); return 0; 3.暂停线程 g_EventThreadPause.ResetEvent(); 4.恢复线程 g_EventThreadPause.SetEvent(); 5.退出线程 g_EventThreadPause.SetEvent(); |
|
来自: chensirDSP > 《我的图书馆》