Forum Discussion

chaklasiyanikun's avatar
4 years ago
Solved

Faced "Execution timeout (runtime error &h23)" Error in Function Calculation

I make one sample App for Roku. It is as below. MainScene.brs sub init() m.TaskNodeThread = CreateObject("roSGNode", "TaskNodeThread") m.TaskNodeThread.control = "RUN" end sub MainScene.xm...
  • necrotek's avatar
    4 years ago

    Review the documentation on correctly setting up a task

    https://developer.roku.com/docs/references/scenegraph/control-nodes/task.md

    the way you have set this up 'testContentFunction(testData)' will run when created

    MainScene.brs set testdata for task here before "run"

    sub init()
        m.TaskNodeThread = CreateObject("roSGNode", "TaskNodeThread")
    m.TaskNodeThread.TestContent=testData
    m.TaskNodeThread.observefield("resultContent","onResultContentChanged") 'observe field to see if we are done with task
    m.TaskNodeThread.control = "RUN"
    end sub

    sub onResultContentChanged(event) 'called when task completes
    data=event.getdata()
    'do stuff with data here
    end sub

    TaskNodeThread.xml needs and interface for test content

    <?xml version="1.0" encoding="UTF-8"?>
    <component name="TaskNodeThread" extends="Task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
    <interface>
    <field id = "resultcontent" type = "node" /> <field id = "testcontent" type = "node" /> </interface>
    <script type="text/brightscript" uri="pkg:/components/TaskNodeThread.brs" /> </component>

    TaskNodeThread.brs m.top.functionName is what is called when .control="run" is set

    sub init()
    m.top.functionName = "testContentFunction" end sub

    function testContentFunction() as String
    testdata=m.top.testcontent
    'do stuff here
    m.top.resultContent = resultOfStuffDone 'signal task has completed
    end function