Yielding Control

Windows is a nonpreemptive multitasking system. This means that Windows cannot take control from an application. The application must yield control before Windows can reassign control to another application.

To make sure that all applications have equal access to the CPU, the GetMessage function automatically yields control when there are no messages in an application queue. This means that if there is no work for the application to do, Windows can give control to another application. Since all applications have a message loop, this implicit yielding of control guarantees sharing of control.

In general, you should rely on the GetMessage function to yield for your application. Although a function (Yield) is available that explicitly yields control, you should avoid using it. Since there might be times when your application must keep control for a long time, such as when writing a large buffer to a disk file, you should try to minimize the work and provide a visual clue to the user that a lengthy operation is underway.