vc 线程的创建,暂停和结束

  1.线程的创建: 
      (1)CWinThread* MainThread; 
       MainThread=AfxBeginThread(MyThread,this,THREAD_PRIORITY_NORMAL,0,0,NULL ); 


       (2)后台工作线程函数 
                  UINT MyThread( LPVOID pParam ) 
                   { 
                       C类Dlg * pDlg = (C类Dlg*)pParam; 

                       pDlg->Function(pDlg->parament); 
                       return 0; 
                  } 

                 (3) Function(parament)//////用来执行的函数 
                 { 
                 } 
2.线程的暂停和继续: 
                          暂停线程:MainThread-> SuspendThread () 
                          继续线程:MainThread-> ResumeThread () 

3.线程那个的停止
 
                         (1).判断状态://看线程是否运行
                                               DWORD code; 
                                               GetExitCodeThread(MainThread-> m_hThread, &code); 
                                              if(code == STILL_ACTIVE) 
                                             {   
                       (2)结束线程     TerminateThread(MainThread-> m_hThread,   0); 

                                                 }



http://blog.csdn.net/halibobo520/article/details/3371975

你可能感兴趣的:(VC/MFC)