SuspendThread and ResumeThread
记录下,用于复现
#include <windows.h>
#include <iostream>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
DWORD WINAPI createyourwindow(LPVOID param)
{
WNDCLASSEXW wcex = { 0 }; wcex.cbSize = sizeof(WNDCLASSEX);
HWND* hWnd = (HWND*)param;
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = GetModuleHandle(NULL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszClassName = L"MyClass";
RegisterClassExW(&wcex);
*hWnd = CreateWindowW(L"MyClass", L"window", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, GetModuleHandle(NULL), NULL); if (!*hWnd)
{
return FALSE;
} ShowWindow(*hWnd, SW_NORMAL);
UpdateWindow(*hWnd);
MSG msg; // Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, NULL, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
} int main()
{
DWORD ThreadId;
HWND hwnd = NULL;
HANDLE hThread = CreateThread(NULL, 0, createyourwindow, (LPVOID)&hwnd, 0, &ThreadId);
MSG msg;
DWORD tid = GetCurrentThreadId(); // used in the PostThreadMessage().
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (msg.message == WM_USER && hwnd != NULL)
{
SuspendThread(hThread);
printf("suspend\n"); getchar(); //To Do here. ResumeThread(hThread);
}
}
WaitForSingleObject(hThread, INFINITE);
return 0; }
#include <windows.h>
#include <iostream>
int main()
{
DWORD tid = 14328;
PostThreadMessage(tid, WM_USER, 0, 0);
return 0;
}
SuspendThread and ResumeThread的更多相关文章
- 常用的WinAPI函数整理
常用的WinAPI函数整理 一.进程 创建进程: CreateProcess("C:\\windows\\notepad.exe",0,0,0,0,0,0,0,&s ...
- Worker Thread
http://www.codeproject.com/Articles/552/Using-Worker-Threads Introduction Worker threads are an eleg ...
- C++实现线程池 .
C++实现线程池. 欢迎转载,转载请注明原出处:http://blog.csdn.net/ithzhang/article/details/9020283 代码地址:https://github.co ...
- windows 线程
在windows中进程只是一个容器,用于装载系统资源,它并不执行代码,它是系统资源分配的最小单元,而在进程中执行代码的是线程,线程是轻量级的进程,是代码执行的最小单位. 从系统的内核角度看,进程是一个 ...
- 20160226.CCPP体系详解(0036天)
程序片段(01):01.多线程.c+02.多线程操作.c 内容概要:多线程 ///01.多线程.c #include <stdio.h> #include <stdlib.h> ...
- Atitit sleep原理 node.js sleep解决方案 timer
Atitit sleep原理 node.js sleep解决方案 timer sleep()的实现分为三步: 1.注册一个信号signal(SIGALRM,handler).接收内核给出的一个信 ...
- windows下进程与线程剖析
进程与线程的解析 进程:一个正在运行的程序的实例,由两部分组成: 1.一个内核对象,操作系统用它来管理进程.内核对象也是系统保存进程统计信息的地方. 2.一个地址空间,其中包含所有可执行文件或DLL模 ...
- pthread到Win32thread
一.什么是线程. 线程(thread)是为了提高系统内程序的并发(concurrency)执行程度而提出来的概念,它是比进程更小的能够独立运行的基本单位.在引入线程的系统中,线程是处理器调度(sche ...
- C语言多线程编程一
1. Windows下同时打开多个对话框: #include <Windows.h> #include <process.h> //创建线程 void runmsg(void ...
- MFC【17-1】线程和线程同步化
17.1线程 对于Windows来说所有的线程都是一样的,但MFC却把线程区分为两种类型:User Interface(UI) threads(用户界面(UI)线程)和Worker threads(工 ...
随机推荐
- [转帖]离线部署单机kubenetes-1.28.4
系统版本: openEuler 22.03 (LTS-SP2) docker版本:24.0.7 kubenetes版本: 1.28.4 虚机IP: 192.168.177.138 基于 https:/ ...
- [转帖]Nacos使用2.0.1版本启动出现9848端口错误的解决方式(亲测有效)
目录 一.背景 二.报错如下 三.报错原因 四.解决方式 一.背景 nacos服务端和客户端都是 2.x版本. centos7使用原始安装nacos单机版,没有使用docker安装naocs集群. 二 ...
- [转帖]minio性能测试
https://zhangzhuo.ltd/articles/2021/09/08/1631106274550.html 压测参数说明 压测数据量为:2个backet,每个backet为10000对象 ...
- [转帖]jmeter 响应时间rt很小,但是tps也很小&jmeter,脚本处理,千万不要用js
一.背景: 在压测的时候,查看jmeter聚合报告,发现rt很小,但是tps也很小. 讲道理来说,响应时间越小,tps应该越大. 一共压测10分钟,发现jmeter请求的样本数量非常小,才8500个请 ...
- [转帖]使用SkyWalking监控nginx (以openresty为例)
https://www.cnblogs.com/hahaha111122222/p/15829737.html 安装使用SkyWalking先看这篇文章,地址:https://www.cnblogs. ...
- [转帖]Windows磁盘性能压测(2)-Fio
http://www.manongjc.com/detail/59-qftscgqzitmxpaw.html 目录 一.腾讯云官网硬盘性能指标 二.使用fio测试硬盘性能指标 1. 测试工具相关 2. ...
- [转帖]适用于 Azure VM 的 TCP/IP 性能优化
https://learn.microsoft.com/zh-cn/azure/virtual-network/virtual-network-tcpip-performance-tuning?con ...
- .NET 使用Camunda快速入门
简介参考:https://www.cnblogs.com/lvdeyinBlog/p/16095603.html 一.工作流介绍 1. 什么是工作流 工作流(Workflow),是对工作流程及其各操作 ...
- 【4】配置和运行Opencv常见的一些问题总结,以及bug解决。
相关文章: [1]windows下安装OpenCV(4.3)+VS2017安装+opencv_contrib4.3.0配置 [2]Visual Studio 2017同时配置OpenCV2.4 以及O ...
- Android 开机流程介绍
目录 一.目的 二.环境 三.相关概念 3.1 Android平台架构 3.2 Android启动架构 3.3 zImage 3.4 RAMDISK 3.5 RC文件 四.详细设计 4.1 Boot ...