Microsoft KB Archive/71670

-

{|
 * width="100%"|

The information in this article applies to:
 * Microsoft Windows Software Development Kit (SDK) for Windows ' versions 3.0, 3.1

SUMMARY
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 &quot;batch&quot; 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 &quot;batch size&quot; 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:


 * 1) Allows the user to cancel the background processing before all the rectangles have been drawn (by choosing the Cancel button)
 * 2) Indicates both the total number of rectangles to be drawn and the batch size
 * 3) Displays a &quot;gas gauge&quot; that indicates the percentage of the background task that has been completed

BACKGRND can be run along with another Windows-based application (for example, Notepad) to illustrate the difference between &quot;polite&quot; and &quot;impolite&quot; background processing. If the batch size is set to a &quot;polite&quot; 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 &quot;impolite&quot; 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.

MORE INFORMATION
The following file is available for download from the Microsoft Software Library:

~ BackGrnd.exe (size: 33826 bytes) For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base: ARTICLE-ID: Q119591 TITLE    : How to Obtain Microsoft Support Files from Online Services
 * }

-

Last reviewed: July 6, 1998

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.