Windows API一日一练(50)SuspendThread和ResumeThread函数
来源:互联网 发布:mac 如何安装ipython 编辑:程序博客网 时间:2024/06/01 08:16
操作系统对线程有几种状态的变化:执行,挂起和恢复执行。
当线程做完任务或者现在想暂停线程运行,就需要使用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函数
- LINQ
- 小试一把 64 位 Windows 编程
- 候捷谈Java反射机制(二)
- 在Gridview中设置日期字段的显示格式为yyyy-MM-dd
- 去掉 deplate(Viki) 生成的 html 文件行尾多余的空格。
- Windows API一日一练(50)SuspendThread和ResumeThread函数
- CC2e:《代码大全(第2版)》集萃
- Asp.net 2.0 自定义控件开发[实现自动计算功能(AutoComputeControl)][示例代码下载]
- Windows API一日一练(49)SetThreadPriority和GetThreadPriority函数
- zlib 在 Visual Studio 2005 下编译失败的解决办法
- JavaScript组件之JQuery(A~Z)教程(基于Asp.net运行环境)[示例代码下载]
- Windows API一日一练(48)PostThreadMessage函数
- 向Word和PowerPoint插入LaTeX公式的小工具
- 候捷谈Java反射机制(一)