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
浏览次数:11
分类:技术文章
本文共 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月21日 01时17分04秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
PCB走线角度为90度到底行不行?
2019-04-29
这个 17 岁的黑客天才,破解了第一代 iPhone!
2019-04-29
在STM32价格疯长下,哪些国产32可以替代?
2019-04-29
半导体芯片原厂涨价及调价声明新增了这些!
2019-04-29
为什么你学C++这么难?
2019-04-29
无人机破巡检难题,秒变电网卫士
2019-04-29
五年,我成为了一名嵌入式工程师。
2019-04-29
2020年电赛题目,命题专家们怎么看?
2019-04-29
PCB元器件摆放不可忽略的10个技巧
2019-04-29
掌握AI核心技术没有秘籍,能自己创造就是王道
2019-04-29
大学老师的月薪多少?实话实说:4万多一点……
2019-04-29
2020年电赛题目,命题专家权威解析!
2019-04-29
如何掌握“所有”的程序语言?没错,就是所有!
2019-04-29
39岁单身程序员入住养老院
2019-04-29
写论文,这个神器不能少!
2019-04-29
我在哥大读博的五年,万字总结
2019-04-29
本科、硕士、博士,究竟有何区别?
2019-04-29
如果我的实验室也这样布置,那多好。
2019-04-29
现在做硬件工程师还有前途吗?
2019-04-29
用 50 种编程语言写“Hello,World!”
2019-04-29