Because the
event loop that retrieves and dispatches events is common amongst applications, many programming frameworks provide an implementation of an event loop, and the application developer only needs to write the event handlers.
RPG, an early programming language from
IBM, whose 1960s design concept was similar to event-driven programming discussed above, provided a built-in main
I/O loop (known as the "program cycle") where the calculations responded in accordance with "indicators" (
flags) that were set earlier in the cycle.
Event handlers The actual logic is contained in event handler routines. These routines handle the events to which the main program will respond. For example, a single mouse-click on a "Save" command button in a
GUI program might trigger a routine to save data to a
database. An "Exit" button might trigger a routine to exit the program. The event loop receives events from all such command buttons and other
GUI elements, dispatching the appropriate event handler routine for each button. Event handler routines need to be bound to specific events, so the event loop can dispatch the correct routine in response to the event. Many
IDEs simplify this process by providing the programmer with an event handling template for each specific event (such as a button click), allowing the programmer to focus on writing the event-handling code. In a sequential program, keeping track of execution order and history is normally trivial. But in an event-driven program, event handlers execute non-sequentially in response to external events. Special attention and planning is required to correctly structure the event handlers to work when called in any order. ==Common uses==