This control flow uses Messages to transfer control. The main program consists of an endless control loop. In each cycle of this loop, it passes all messages that have been sent to all modules that registered themselves to receive messages of this type. Each module then processes the message. The module may publish new messages in this process. These messages will be multicast only at the next control cycle.

Command structure: Control Loop; Order of execution: Sequential.

This control flow has been introduced by modern GUI programs. It is famous for waiting most of the time. Its base is a tiny loop, called the "idle loop", that just checks if the user has done something. Only when the user has pressed a key, or clicked a mouse button, or when a timer has timed out, the flow of control is transferred to a predefined part of the program, called an "event-handler". The event-handler reacts to the event, in typically a very short time. When it is done, it returns control to the idle-loop. If the handler needs more time, it should spawn a separate thread of control to perform the time-consuming action.

Links