Copy link to clipboard
Copied
Hey y'all,
I'm trying to figure out how to add a wait timer to my while loop in Automation Blocks.
I want it to wait 1 second before it executes again.
I need this for sync folders so it checks them to sync again every 1 second instead of hammering the system resources and syncing every nanosecond.
Any help or advice would be greatly appreciate to help me solve this.
If this is completely impossible then I ask the developers of Automation Blocks to please add this functionality.
Copy link to clipboard
Copied
Well the extendscript command to wait is:
$.sleep(1000);
Where 1000 can be any amount of milliseconds.
And while I'm not very familiar with Automation Blocks myself, it looks like you can run custom extendscript commands via the "Pr Other" option then put the above command into the 'execute code' field, like this:
Which you should be able to place into your existing while loop.
Optionally if you want to simplify the look of it, since clicking "Pr Other" seems to add the variable stuff which isn't actually necessary here, it looks like you can click the gear on the block and select and delete the 'item' thing, which leaves just the execution part like this below.
Copy link to clipboard
Copied
I would be carefull with $.sleep() — ExtendScript engine is synchronous. It waits for a command to be executed and then proceeds to next task.
If you execute $.sleep(1000), it will block whole ExtenScript for 1 second, meaning no other extension will be able to access it. You can check it easily, by trying to open Export tab (it also relies on ExtendScript): nothing will happen.
If you put sleep in forever loop it means ExtendScript will be occupied by your process forever.
Copy link to clipboard
Copied
Good point, thank you!!
How could I solve this?
Copy link to clipboard
Copied
@ThioJoe thank you very much that is exactly what I was looking for! Much appreciated.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more