wait until called method finishes

Hi - I have a method, evalJavascript(JS) which invokes another method, which wraps a call to ExecuteJavascriptXC(JS, weakAddressOf ) from Jeremie R’s iOSExtensions module. Standalone, invoked once, it runs well.

When I stack a number of evalJavascript calls, one after the other, the ExecuteJavascriptXC’s all run sequentially, and the handler doesn’t start its first execution until all the ExecuteJavascriptXCs are invoked. What I need is a way to delay the execution of each ExecuteJavascriptXC’s until each completes.


use a timer and a semaphore system.

start the first call, start the timer(say 100ms) in the timer look for the semaphore value.
after the first call finishes set the semaphore value and the timer will call the next one.

a very rough explanation but I think you will understand what I mean.

I did that; given the sheer number of calls I was hoping for a procedure that was responsive to the semaphore without timer intervention for better responsiveness. But thanks.

it can only be as responsive as the network allows, I would say its not possible to ‘make’ it more responsive than the timer/semaphore method as the only loss in time is the period between the end of the first process and the timer period, which if the timer period is small, say 100ms then that the most you can improve it by per call.

if you need so many calls then perhaps a refactor of the app is worth looking into to reduce the requirement for the network connection periods.

you can’t beat physics! unfortunately…

It’s not a network connection issue; I have hundreds of calls to this method (populating an iOSHTMLViewer with various widgets) and would like to minimize the load time. There is a certain overhead with servicing a timer event, and I’m hoping that there’s a more instantaneous way…

I do this by chaining each one in the AddressOf handler, so when one completes it calls the next one. It’s a bit spaghetti-like but I don’t know a neater way to do it.