This computer checks the system clock, and every second it triggers a ClockTick event. The programmer had to write an event handler for the ClockTick event:
on ClockTick: add one to the seconds counter and display the new value.
Here is a second version of the program in which the user can specify the time between ClockTick events.
You have seen other examples of events that are not triggered by the user. For example, when you receive an instant message, the event handler displays a notification. Or, when a Web server receives a request for a particular page, the event handler retrieves that page and sends it back to the client that requested it. Computers are also embedded in cars and all sorts of appliances. When the clock on your microwave oven reaches 0, it has been programmed to turn off the cooking element and beep.
Initially we will focus on events triggered by user actions, but later we will look at others.