Keeping UI reactive during long lasting process

Hi! I made a simple GUI application that performs, once the start button has been pressed, a longer lasting process (involving a Web View). I want to give the user the possibility to interrupt it but the GUI isn’t reactive during that process. Do I need to start another thread or is there any possibility to give responsiveness to the UI every some milli seconds during this long lasting process (e. g. in Delphi one can write Application.ProcessMessages()). Thank you for your hints!

You can put the code on a background thread, but there are traps doing that in AppleScriptObjC. You’re probably better having your code check for new events at regular intervals. An easy way to do this is to use the fordEvent method from the ObjectWithFords class in Myriad Helper. You can download it here:

Then you just need to call fordEvent() at regular intervals.

Of course if one command takes a long time, even that won’t help. If it’s something using a shell command, NSTask can be used to run it in the background.

Dear Shane, the implementation of the fordEvent() was exactly what I was looking for. Thank you very much for pointing me to this tools site. Despite the fordEvent method it seems to have a lot more of helpful tools.