Event occurring during execution of the handler of a previous event lazarus / 31-LCL ---------------------------------------------------------------------- Relativity · 2015-11-19 16:17 If a second event occurs during the execution of the eventhandler of a previous first event, then what happens exactly? Is the execution of the eventhandler of the first event interrupted, in order to start the execution of the eventhandler of the second event and is the execution of the first eventhandler resumed after the end of the second eventhandler ? Or does the execution of the second eventhandler start only after the execution of the first eventhandler has been completed ? Is there any documentation on this subject ? ---------------------------------------------------------------------- taazz · 2015-11-19 16:49 Quote from: Relativity on November 19, 2015, 05:17:40 pmIf a second event occurs during the execution of the eventhandler of a previous first event, then what happens exactly? what kind of event? What raised it? Quote from: Relativity on November 19, 2015, 05:17:40 pmIs the execution of the eventhandler of the first event interrupted, in order to start the execution of the eventhandler of the second event and is the execution of the first eventhandler resumed after the end of the second eventhandler ? Depends, does the code in the first event in any way causes the second event to be raised? Quote from: Relativity on November 19, 2015, 05:17:40 pmOr does the execution of the second eventhandler start only after the execution of the first eventhandler has been completed ? Is there any documentation on this subject ? If you are talking about pascal object events in general they are not interrupted, unless the code executed during the event raises the second event. Having said that you have to make sure that each event is self sustained and never make any assumptions on the order they will be raised. ---------------------------------------------------------------------- Relativity · 2015-11-20 09:14 I mean the events foreseen for the components available in the component palette, like TButton etc.. For example, for the TButton component you have the events "OnClick", "OnExit" etc..: I mean these events. I have always assumed that, for example, if you click a button while the handler of the "OnClick"-handler of another button is being executed, then first the handler of the first event is completed and only thereafter the "OnClick"-handler of the second button is started. I assumed this. But recently I developed an application with two TTimer, that can run simultaneously but indipendent from each other. Each of the two "OnTimer"-event handlers shows an own message dialog where the user must click "OK". Running the program, when at a point the time of one of the Timers runs out and its message dialog shows up and waits for me to click "OK" (while it waits, it still is in the event handler, standing by), if I wait for a while, then meanwhile eventually the second timer's time will also run out and its message dialog shows up as well (asking for "OK"), although I haven't still clicked the "OK" in the first message dialog and therefore the execution of the first event handler had not yet been completed. This means that the event handler for the second event is executed although the first event's handler has not yet been completed. Is therefore my aforementioned assumption wrong ? ---------------------------------------------------------------------- balazsszekely · 2015-11-20 10:27 QuoteThis means that the event handler for the second event is executed although the first event's handler has not yet been completed.Two events are not interlinked by default, but one event can trigger another one. The answer to your question is yes,  the second event will be executed although the first one is still running. If you want to stop this just set a global boolean variable  to true. ---------------------------------------------------------------------- engkin · 2015-11-20 14:13 Quote from: Relativity on November 20, 2015, 10:14:09 amI have always assumed that, for example, if you click a button while the handler of the "OnClick"-handler of another button is being executed, then first the handler of the first event is completed and only thereafter the "OnClick"-handler of the second button is started. I assumed this. Your assumption is true. Quote from: Relativity on November 20, 2015, 10:14:09 amBut recently I developed an application with two TTimer, that can run simultaneously but indipendent from each other. Each of the two "OnTimer"-event handlers shows an own message dialog where the user must click "OK". Running the program, when at a point the time of one of the Timers runs out and its message dialog shows up and waits for me to click "OK" (while it waits, it still is in the event handler, standing by), if I wait for a while, then meanwhile eventually the second timer's time will also run out and its message dialog shows up as well (asking for "OK"), although I haven't still clicked the "OK" in the first message dialog and therefore the execution of the first event handler had not yet been completed. This means that the event handler for the second event is executed although the first event's handler has not yet been completed. Is therefore my aforementioned assumption wrong ? Timer events are fired by the system (Windows at least). They are not fired by the application event loop. That's why they do not adhere to your assumption. ---------------------------------------------------------------------- Relativity · 2015-11-23 08:29 Everything is clear. Thanks to everybody.