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);

                                                 }

<linker : http://blog.csdn.net/halibobo520/article/details/3371975>

转载于:https://www.cnblogs.com/MMLoveMeMM/articles/3134639.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值