partyk1d24
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
09:12 AM
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.
Any help would be great.
28 REPLIES 28

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
09:36 AM
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
Where in the Developer Guide do you see that it says multithreading is supported?
--Mark
partyk1d24
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
09:57 AM
Re: Information on multi-threading
From said documentation...
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?
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?

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
10:21 AM
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
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
partyk1d24
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
10:38 AM
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?

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
10:41 AM
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
--Mark

NewManLiving
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
12:30 PM
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
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 )
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2014
02:23 PM
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
sanyam
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
07:33 PM
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?
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?

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
07:45 PM
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)