How to utilize the application's spare time?
来源:互联网 发布:87版红楼梦 知乎 编辑:程序博客网 时间:2024/05/08 06:14
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();
}
}
...{
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
.
- How to utilize the application's spare time?
- How to check the entitlements on my Application's Signature
- How to Build an Economic Model in Your Spare Time (如何利用业余时间建立经济模型)
- How To Use the C Run-Time
- How to get the current epoch time
- How to calculate the undo_retention time
- How to install, compile, and utilize Rebar in Windows
- How to schedule the thread's priority?
- How to write the Gridview's RowCommand
- utilize matlab to implement the image processing (1)
- How to set the QT Application icon in the windows.
- Android: how to resolve Application’s parameter NullPointerException
- How the Application Server's Web Container Works
- When it’s time to quit, that’s the time to carry on.
- how to initialize the vp for second time
- How to estimate the time required for a program.
- how to print the spend time of one function
- five minutes to spare
- 输入异常判断(EXCEPTION)
- 感触
- 如何在虚拟机里装Linux
- 翻译(四):这本书的结构是怎样的(二)
- 二维数组的动态创建
- How to utilize the application's spare time?
- ORACLE中的子查询
- 一位软件工程师的6年总结
- Spring学习笔记之Spring的bean生命周期
- 权威专家推荐的最佳安全图书
- MANGOS中的地图管理
- 批评的力量
- C# Arrays
- 创建二级联动类