Process background events while running Script

I use the Scripter Engine to fill a table with information resp. do calculations. Therefore I have a for-loop which needs several seconds to finish. During that time the program freezes and does not react to any other user input.

I put Application.ProcessMessages inside the for loop. That solved my problem partly. While the script is running I can click buttons, checkboxes and so on. Timer events are also triggered. That's good so far.
But all things which are triggered by Actions (TActionList/TAction => Vcl.ActnList) are not working. Actions are not executed until my script has finished.

What can I do to make Actions triggered during the runtime of my script?

This looks a use cade for threads. Use a thread and execute your script from it. Since scripter is not thread-safe, you should use a specific scripter component just for that thread, do not use it to execute scripts in multiple threads.

I did not understand your answer fully...

Do you think I should

  1. Start a thread inside my Script to do the time consuming calculation
  2. Start the whole script in Delphi out of a thread?

What do you mean with "a specific scripter component just for that thread"?

Do you have a small example?

Create a thread, and inside the thread you should create the scripter component, set the source code, execute, then leave.

Yes, actually there is a demo inside the folder \demos\pascal\threads.

Is it also possible that only a small part of a script can be a thread?

No, that is not possible.