-- DOESN'T WORK!
-- Results mingled and in wrong order.
-- Might even crash.
on testA
put "TEST A"
cnt = 3
repeat with i = 1 to cnt
props = [:]
props["cb_target"] = _movie
props["cb_complete"] = #completeCallback
props["cb_stdout"] = #stdoutCallbackA
props["timeout"] = 0
cmd = "ping -n 2 127.0.0.1>nul&echo "&i -- takes about 1 sec
shell_cmd_thread(cmd, props)
end repeat
end
-- WORKS!
-- All tasks are executed in a row, in correct order (1, 2, 3).
on testB
put "TEST B"
cnt = 3
fifo = script("CALL_FIFO").new()
fifo.mSetCompleteCallback(#completeCallback)
repeat with i = 1 to cnt
props = [:]
-------------------- REQUIRED!
props["cb_target"] = fifo
props["cb_complete"] = #_finished
--------------------
props["cb_stdout"] = #stdoutCallbackB
cmd = "ping -n 2 127.0.0.1>nul&echo "&i -- takes about 1 sec
actionHandler = #shell_cmd_thread
actionTarget = _movie -- since function shell_cmd_thread is global!
actionParams = [cmd, props]
fifo.mAddCall(actionHandler, actionTarget, actionParams)
end repeat
fifo.mStart()
end
on completeCallback
put "CALL(S) COMPLETE!"
end
on stdoutCallbackA res
if res<>"" then put "STDOUT: "&res
end
on stdoutCallbackB (caller, res)
if res<>"" then put "STDOUT: "&res
end