I think I am seeing a problem related to garbage collection. I am calling a function from my main event loop which initiates some async requests using this function:
function getImageAsync(port, file, url)
u = CreateObject("roUrlTransfer")
u.SetMessagePort(port)
u.setUrl(url)
if not u.asyncGetToFile(file) then
print "getImageAsync() failed!"
end if
return u.GetIdentity()
end function
I am always receiving event code=-10001 (Cancelled). I am able to get it to work by creating the roUrlTransfer objects in the calling function (and saving them in another object). This function now works...
function getImageAsync2(u, port, file, url)
u.SetMessagePort(port)
u.setUrl(url)
if not u.asyncGetToFile(file) then
print "getImageAsync() failed!"
end if
return u.GetIdentity()
end function
I've just started playing with BrightScript, but it appears the roUrlTransfer object is being freed when the function returns even though the request is active. Would this be expected behavior?