Your Digital Media Has Never Looked So Good

Topic Author
Posts: 35
Joined: Mon Jul 10, 2017 6:52 pm

What is the proper way to reuse tasks?

Tue Oct 03, 2017 10:56 am

Right now I have a periodic task that runs every 25 seconds to maintain a session with our backend.

I am executing the following function every 25 seconds.  At some point, I seem to have multiple PlaybackSessionTask tasks running at the same time.  Is there a way to clean up the created tasks once they have completed?  Should I reuse one task and just call start?

function saveSession(titleId, seconds)
    m.playbackSessionTask = createObject("roSGNode", "PlaybackSessionTask")
    m.playbackSessionTask.observeField("response", "handleSaveSession")
    m.playbackSessionTask.functionName = "save"
    m.playbackSessionTask.contentId = titleId
    m.playbackSessionTask.seconds = seconds
    m.playbackSessionTask.control = "RUN"
end function
Posts: 3
Joined: Sat Oct 29, 2016 12:17 am

Re: What is the proper way to reuse tasks?

Thu Oct 05, 2017 4:57 am

You can reuse m.playbackSessionTask task. Just don't create new for m.playbackSessionTask
use the following to be sure previously used task was closed:
m.playbackSessionTask.control = "DONE"

It will finished task thread.
Posts: 146
Joined: Wed Jul 15, 2015 8:30 am

Re: What is the proper way to reuse tasks?

Thu Oct 05, 2017 8:55 am

is DONE new in 7.6+? I though the only valid control setter values were INIT, RUN, or STOP
edit: Never mind, it's been there all along.
Another question about tasks... why is the control value required to be UPPERCASE when set, but is lowercase when get??

Who is online

Users browsing this forum: Tyler Smith and 2 guests