Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
partyk1d24
Visitor

Information on multi-threading

I can't find much information/ any examples of multithreading. Am I missing something in the templates or documentation. The developer guide say that it is possible so I would have to think there are examples somewhere. I get that you are supposed to use message ports but how do you "fire off" a new thread?

Any help would be great.
0 Kudos
28 REPLIES 28
RokuMarkn
Visitor

Re: Information on multi-threading

Brightscript does not support multithreading. See section 4.8 in the Brightscript Language Reference for details.

Where in the Developer Guide do you see that it says multithreading is supported?

--Mark
0 Kudos
partyk1d24
Visitor

Re: Information on multi-threading

From said documentation...

Whether a BrightScript Component launches a background thread to perform asynchronous operations is a decision made by the Object implementer. Often an object will have synchronous and asynchronous versions of the same method.


That to me sounds like I can create a background thread for some tasks. But that is really the only reference, perhaps it is just a typo. So then the question becomes how do I using asynchronous operations without another thread?
0 Kudos
RokuMarkn
Visitor

Re: Information on multi-threading

Ok, thanks. That sentence probably needs to be clarified. It's referring to the underlying C code that implements the Brightscript objects, not to creating threads in Brightscript code.

Certain operations, like HTTP requests using roUrlTransfer, can be done with asynchronous operations. The only way to achieve something like that in your own code is to break up the code into smaller pieces that can be called from your event loop, perhaps based on a timer.

--Mark
0 Kudos
partyk1d24
Visitor

Re: Information on multi-threading

Ok so how would I say handle button clicks while rendering an image? They could never happen at the same time? I would have to handle the rendering then the click? If rendering gets hosed (for whatever reason) doesn't that mean I lose the ability to handle key presses?
0 Kudos
RokuMarkn
Visitor

Re: Information on multi-threading

By "rendering an image", do you just mean doing a DrawObject or something like that? That operation is pretty fast (much less than a frame interval) and cannot get "hosed". Could you explain in more detail the scenario you're concerned about?

--Mark
0 Kudos
NewManLiving
Visitor

Re: Information on multi-threading

Theoretically, If you really need to you can download your graphics
Asynchronously using asyncgettofile. This writes it
To the temp directory. You then load them
From there which is very quick. If you need to check
For keypress just use the same port as your
Window. Checking for both types of events to come in
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
TheEndless
Channel Surfer

Re: Information on multi-threading

"NewManLiving" wrote:
Theoretically, If you really need to you can download your graphics
Asynchronously using asyncgettofile. This writes it
To the temp directory. You then load them
From there which is very quick. If you need to check
For keypress just use the same port as your
Window. Checking for both types of events to come in

Or use the roTextureManager, which can download and load the bitmap asynchronously.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
sanyam
Visitor

Re: Information on multi-threading

I am implementing Lazy Loading of images in a carousel made on roScreen. There are around 100 images which I am fetching from the web. I am using roTextureEvent to get the images asynchronously and drawing the objects on the screen. In this approach, when the requests for the images are fired, I am not able to handle the button events as the request send process seems to be slow. I want an roGridScreen type experience where images can be loaded even if the scrolling is happening.
I have tried to make my code into as small bits as I could. But the experience remains the same.
Could you please guide me if there is a way?
0 Kudos
TheEndless
Channel Surfer

Re: Information on multi-threading

"sanyam" wrote:
I am implementing Lazy Loading of images in a carousel made on roScreen. There are around 100 images which I am fetching from the web. I am using roTextureEvent to get the images asynchronously and drawing the objects on the screen. In this approach, when the requests for the images are fired, I am not able to handle the button events as the request send process seems to be slow. I want an roGridScreen type experience where images can be loaded even if the scrolling is happening.
I have tried to make my code into as small bits as I could. But the experience remains the same.
Could you please guide me if there is a way?

We'd need to see your code. There may be a slight delay when you issue the request (<10ms), but nothing that should prevent you from handling button events.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.