The Event Loop The event loop is the part of the program that performs a loop of waiting for new events, recognizing them, and dispatching callbacks for dealing with these events. The event loop is also used as a point for integration with various network resources and the like, as we'll later see. When the program wishes to exit (e.g. the user chose 'exit' in a menu), it marks this with a flag that is checked by the main loop, which will exit, instead of processing the next event. The events are kept in a queue, and are normally processed sequentially, but often the program has a method to query the contents of the queue, and handle some events that are not at the front of the queue.