SAMPLE: BACKGRND Demonstrates Background ProcessingLast reviewed: February 15, 1996Article ID: Q71670 |
The information in this article applies to:
BACKGRND uses a PeekMessage() loop to do background processing. The background task is to draw rectangles at random in the application's client window. BACKGRND draws one "batch" of rectangles each time through the PeekMessage() loop, and all the rectangles in each batch are drawn in the same color. This provides a visual indication of how much background work is done before BACKGRND offers to yield. Both the "batch size" and the total number of rectangles drawn can be changed using a menu selection. BACKGRND does not replace the main GetMessage() loop with a PeekMessage() loop. Instead, it enters a PeekMessage() loop only when the user chooses the Draw! menu item. While it draws the rectangles, BACKGRND displays a modeless dialog box that:
If the batch size is set to a "polite" small value (for example, 10 rectangles each time through the PeekMessage loop), the user can easily type within Notepad while BACKGRND is drawing rectangles. BACKGRND draws rectangles in the spare time slices between the messages generated by the user's keystrokes, and calls PeekMessage() often enough that the user will still find Notepad responsive. If the batch size is set to an "impolite" large value (for example, 1000 rectangles each time through the PeekMessage() loop), BACKGRND can complete its background job much more quickly, because there are fewer calls to PeekMessage() and thus less overhead. However, a user trying to type in Notepad will find the keyboard so unresponsive that Notepad will be essentially useless. Download BACKGRND.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
|
Additional reference words: 3.00 3.10 softlib BACKGRND.EXE
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |