线程SuspendThread() ResumeThread()的使用
来源:互联网 发布:优酷网络连接失败 编辑:程序博客网 时间:2024/05/16 16:19
SuspendThread():挂起线程 If the function succeeds, the return value is the thread's previous suspend count; otherwise, it is (DWORD) -1.
ResumeThread():启动线程 If the function succeeds, the return value is the thread's previous suspend count; otherwise, it is (DWORD) -1.
If the return value is zero, the specified thread was not suspended. If the return value is 1, the specified thread was suspended but was restarted.
If the return value is greater than 1, the specified thread is still suspended.
在满足条件时启动线程,不满足条件时挂起线程
CWinThread *pthread;创建线程pthread=AfxBeginThread(ThreadProc,(LPVOID)this,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED,NULL)
if(condition){ DWORD r=pthread->ResumeThread(); if(r==-1) "启动线程失败"}else{//挂起线程 DWORD suspendcount=pthread->SuspendThread(); if(suspendcount==-1) "挂起线程失败" else { for (DWORD i = 0; i < suspendcount; i++)//如果挂起多次,需要启动多余挂起的次数,保证只挂起一次,否则满足条件时线程并不能启动 { pthread->ResumeThread(); } }}
1 0
- 线程SuspendThread() ResumeThread()的使用
- SuspendThread、ResumeThread
- windows线程挂起与唤醒,SuspendThread与ResumeThread的一些相关问题
- SuspendThread和ResumeThread函数
- SuspendThread和ResumeThread
- SuspendThread和ResumeThread函数
- Windows API--SuspendThread和ResumeThread函数
- ResumeThread用于一个已结束的线程
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- 关于http chunk
- 下拉刷新组件 PullToRefreshListView的使用
- 《Java编程思想》阅读笔记之第一章对象导论
- 第五章
- 京东首页之页面主体、配送方式
- 线程SuspendThread() ResumeThread()的使用
- 变量和数据类型
- 树链剖分
- Ubuntu14.10中为Android Studio设置桌面快捷方式
- 问题三十七:C++怎么解一元四次方程?(1)——怎么解一元二次方程
- SpringBoot集成springfox-swagger2构建restful API
- STM32与DP83845C硬件调试总结
- Spark朴素贝叶斯(naiveBayes)
- zoj2104