How to utilize the application's spare time?
In our message loop, the first thing we do is check the message queue for messages to our application. This is accomplished by calling the
发布日期:2022-02-07 06:39:36
浏览次数:10
分类:技术文章
本文共 1528 字,大约阅读时间需要 5 分钟。
A window application will enter the idle time if there is no message waiting for processing. So how to utilize this interval time to do opearions.
Generally, a window message loop is like this:
while(GetMessagee(& msg,NULL,NULL,NULL)... { TranslateMessage(&msg); DispatchMessage(&msg);}
If we didn't receive any system message, we can use this "spare time" of our application to do some background processing and even do some stuff. This process is called Idle Processing. We need to insert our message loop right after the initialization of our global variables.
while ( TRUE )... { MSG msg; if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) ...{ // Check for a quit message if( msg.message == WM_QUIT ) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } else ...{ ProcessIdle(); }}
PeekMessage
function. If the function returns true, we call TranslateMessage
and DispatchMessage
so that the messages received by our program are processed. If we have no message, we'll call another function called ProcessIdle
.In our message loop, the first thing we do is check the message queue for messages to our application. This is accomplished by calling the PeekMessage
function. If the function returns true, we call TranslateMessage
and DispatchMessage
so that the messages received by our program are processed. If we have no message, we'll call another function called ProcessIdle
. 转载地址:https://blog.csdn.net/wyfeizj/article/details/1908066 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2024年04月23日 13时31分07秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Java笔记-编码方式创建kaptcha验证码
2019-04-27
Java笔记-腾讯验证码平台使用实例
2019-04-27
Java笔记-手机验证码实现
2019-04-27
Spring Boot笔记-普通异常错误截取及构造错误页面
2019-04-27
Spring Boot笔记-拦截器相关(用户权限方面)
2019-04-27
C++笔记-解决VS2015Qt项目MSB3758.MSB4036
2019-04-27
Java笔记-JSP初步研究
2019-04-27
Qt笔记-QSerialPort的使用(串口通信简单实例)
2019-04-27
Leaflet工作笔记-多个标签在地图显示不关闭
2019-04-27
Leaflet工作笔记-GIS地图上构造echarts的3D图
2019-04-27
Kafka笔记-kafka外网搭建及构建生产者
2019-04-27
Kafka笔记-Spring Boot消费者构造
2019-04-27
Spring Boot笔记-Hibernate中@ManyToOne及@OneToOne
2019-04-27
Web笔记-session及cookie
2019-04-27
Java笔记-Spring Boot生成MD5摘要
2019-04-27
MySQL笔记-唯一键的使用
2019-04-27
Web笔记-移动前端开发笔记
2019-04-27