Windows API一日一练(50)SuspendThread和ResumeThread函数
来源:互联网 发布:初学者电钢琴推荐 知乎 编辑:程序博客网 时间:2024/06/05 16:12
操作系统对线程有几种状态的变化:执行,挂起和恢复执行。
当线程做完任务或者现在想暂停线程运行,就需要使用SuspendThread来暂停线程的执行,当然恢复线程的执行就是使用ResumeThread函数了。这两个函数使用很简单的,下面就来看看例子是怎么样使用的。
函数SuspendThread和ResumeThread声明如下:
WINBASEAPI
DWORD
WINAPI
SuspendThread(
__in HANDLE hThread
);
WINBASEAPI
DWORD
WINAPI
ResumeThread(
__in HANDLE hThread
);
hThread是线程的句柄。
调用函数的例子如下:
#001 //线程的暂停和恢复。
#002 //蔡军生 2007/10/15 QQ:9073204 深圳
#003 void ThreadSuspendResume(void)
#004 {
#005 ::SuspendThread(m_hThread);
#006
#007 Sleep(10);
#008 ::ResumeThread(m_hThread);
#009 }
#010
第5行是暂停线程执行。
第8行是继续线程执行
- 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函数
- 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--SuspendThread和ResumeThread函数
- SuspendThread和ResumeThread函数
- SuspendThread和ResumeThread函数
- .Net环境下基于Ajax的MVC方案
- 隐变量(Hidden Variables)
- PHP - Manual手册 - 特点 - PHP 的命令行模式
- (二)Java游戏部署在Linux平台仿真器上(Motorola)
- 郑昀邀请网站开发工程师架构师加盟Web3.0新锐网站[工作地点-北京财智国际大厦]
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- 无形胜有形——0day破解组织探秘
- 使用TableDiff实用工具解决事务复制中的问题
- Webwork2开发文档
- 简单的方式由数据库的物理表(TABLE)生成实体类(DTO)
- 网管软件发展趋势:智能性、高效性、业务性
- 开源的数据库连接池 SQL Relay 介绍
- 常用的几种交互表存储过程的实现方法
- mscorwks.dll在DotNet中的地位以及在.Net代码保护方面的应用