[Contents] [Previous] [Next]

Event-loop programs

The development of graphical user interfaces began to turn the arrangement shown in Figure 13 inside out. These interfaces allow the user, rather than program logic, to drive the program and decide when certain actions should be performed. Today, most personal computer software accomplishes this by means of an event loop, illustrated by the middle part of Figure 12.

An event loop monitors the mouse, keyboard, and other sources of external events and calls the appropriate parts of the programmer's code according to actions that the user performs. The programmer no longer determines the order in which events occur. Instead, a program is divided into separate pieces that get called at unpredictable times and in an unpredictable order.

By relinquishing control in this way to users, the developer creates a program that is much easier to use. Nevertheless, individual pieces of the program written by the developer still call libraries provided by the operating system to accomplish certain tasks, and the programmer must still determine the flow of control within each piece after it's called by the event loop. Application code still "sits on top of" the system, and the programmer must know what system services are available and when to call them.


[Contents] [Previous] [Next]

Addison-Wesley Publishing Company, Copyright©1995 by Sean Cotter and Taligent,Inc. All rights reserved.