Computer Programming/Event driven programming

In this type of programming, a section of code is written to respond to each event. Events can be user events such as button clicks or mouse moves. Events can also be generated within the computer, for example timer events. Finally, the programmer can generate events.

Responding to an event is sometimes termed handling an event.

The program simply consists of sections that respond to events. These may, in turn use other sections (procedures, methods).

Example
This simple GTK+ program makes a GUI, with a button, that responds to the click event, after we enter a main-loop given by the gtk_main function. When ever events occur, like "clicked" event, we lookup event-handlers connected to it via g_signal_connect function, and delegate functions by invoking them. In this case the handler, btn_clicked is invoked.