What is an event loop?

event loop - or the main loop if it is a central control aspect - is a construct within programs that manage and send events after the initial event. The initial event may be anything, including pressing the keyboard button or by clicking the button in the program. After interviewing the device, the event loop will be sent an event that creates the desired effect on the basis of programming. This is called a loop, not because the event of a circle and occurs continuously, but because the loop prepares for the event, checks the event, sends the event and repeats the process again. This is a block of code that calls the computer to wait for the event and what to do in response to the event. Sometimes the loop occupies only a small part of the coding; It is more often the central logic of the coding document. When they form central logic, it is also called the main loop.

The event for which the event a loop awaits can be anything. The event may manifest from the user who presses the keyboard button, moves the mouse, opens the N applicationEbo anything else that the user can do with the computer. The event usually comes from an external device such as a keyboard or mouse, but it can also be the result of internal processes. When the event is entered, the main loop launches another event in response, such as publishing a letter in the document or allowing the user access to the folder.

Four processes are needed to create an event loop. The first event is called the question to prepare. This prepares the program to question the device or device responsible for the event, so the computer gets the right funds assigned to the event. Then the loop really voice devices for the event to see if the event occurred. The last in this order is the control function that returns the result of the dance to the loop.

If the event returns as true, then the loop continues; If not, he returns to preparation. If it is true, the fourth action - called Dispatch - occurs. This is when all resources are sent to create a response to a queryan event, which caused a reaction. After sending the loop returns to the preparation, prepared again and checked the events.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?