<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2015 Roku Corp. All Rights Reserved. **********-->
<component name="taskdownloaddata" extends="Task">
<interface>
<field id="uri" type="uri" />
<field id="content" type="string" />
</interface>
<script type="text/brightscript">
<![CDATA[
Sub init()
m.top.FunctionName="getNewData"
End Sub
Sub getNewData()
readInternet=createObject("roUrlTransfer")
readInternet.setUrl(m.top.uri)
temp=readInternet.GetToString()
m.top.content=temp
End Sub
]]>
</script>
</component>
"destruk" wrote:
Thanks Enterr. I suppose the point is - if you're using a task node, only run one of each type at a time if you require a callback for it or if it needs to complete in a specific order.
"destruk" wrote:
Another note -- the task thread is about 10 times slower than any other thread. So if you're downloading xml or json data to parse, use the task thread to do the things you require it to do - like use rourltransfer since that's the only way to do it within Scenegraph, and then as quickly as possible toss the result back to the calling thread to parse and process it. Speed is immensely improved doing this than having the task thread do the parsing and manipulation of what it received. When you have the data and have no need for the content field, be sure to unobserve the field, and then set the content field to "" or invalid so it is cleared for the next time you need it. AlwaysNotify for the content field of a task thread didn't appear to work for me - it always appears to be set to False somehow for task threads, ignoring callbacks for observers if the content is the same as it was prior.<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2015 Roku Corp. All Rights Reserved. **********-->
<component name="taskdownloaddata" extends="Task">
<interface>
<field id="uri" type="uri" />
<field id="content" type="string" />
</interface>
<script type="text/brightscript">
<![CDATA[
Sub init()
m.top.FunctionName="getNewData"
End Sub
Sub getNewData()
readInternet=createObject("roUrlTransfer")
readInternet.setUrl(m.top.uri)
temp=readInternet.GetToString()
m.top.content=temp
End Sub
]]>
</script>
</component>