performWithDelay is async?

Hi all,

my task is really simple - wait until asynchronous connection is over and make a message with result of it, but I cannot figure aout any “official” way to force app to sleep() or to wait() for a while. Saw on this forum that people recommeds to use to performWithDelay, but it’s behaviour is still async - it mean script is going further and timer is running in parallel to it…

Any ideas are welcome! Hope it’s my lack of knowledge rather lack of functionality))
Piece of my code, I assume that “aaa” must be printed before “bbb” but it’s not how system behaves

[lua] local parseResponseTimer;
local function ifSomeResults()
print(“timer run”)
print("result.status = ", result.status)
if result.status then
print(“aaa”)
timer.cancel( parseResponseTimer ) – cancel timer

end
end
params.headers = headers
params.body = nil
local string = “?where=” … url.escape(value.encode(criteria))
network.request( baseUrl … “classes” … “/” … class.versions … string , “GET”, networkListener, params)
print (“Connecting to the URL:” … baseUrl … “classes” … “/” … class.versions … string )
result.status = nil;
result.data = nil;
parseResponseTimer = timer.performWithDelay( 500, ifSomeResults, 0 )
– we should not be here until result.status becomes not nil, but we are here!
if result.status == “ok” then
– return received result
pMyRequest.status = “ok”
pMyRequest.message = “Version of Master DB is received”
pMyRequest.data = result.data;
pMyRequest.details = nil;
elseif result.status == “error” then
–return with the reason of not success
pMyRequest.status = “error”
pMyRequest.message = result.message
pMyRequest.details = result.details
else
– we faced time out
pMyRequest.status = “error”
pMyRequest.message = “Connection timed out”
pMyRequest.details = “No reply from parse server”
end
print(“bbb”)[/lua] [import]uid: 182396 topic_id: 31949 reply_id: 331949[/import]