Chapter 14
Not all actions that Microsoft Windows applications undertake are performed in response to user input. Some processing is inherently time-based, such as autosave operations that save documents at 10-minute intervals and updates that involve a clock displayed in a status bar. Windows helps out by providing timers that you can program to send notifications at regular intervals. Another form of temporal processing is idle processing—work performed during "idle" periods when no messages are waiting in the message queue. MFC supplies a framework for idle-time processing in the form of a virtual function named OnIdle that is called whenever the message pump in CWinThread goes to the message queue and finds it empty.
In the first half of this chapter, we'll examine timers, which can be programmed for intervals as low as 55 milliseconds. Here are just a few of the ways in which you can put timers to use:
In the second half of the chapter, we'll look at idle processing—what it is, how it works, and how you can use it to perform background processing tasks in MFC applications.