Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
jackhand
Level 7

Two WHILE loops in the main code?

I currently have two WHILE loops in the main code listening to the port in case particular  events that happen in the components. However, one of the loops is never reached since the 1st while loop loops indefinitely. I could achieve what I want by combining both  WHILE loops into a single WHILE loop, but for business logic reasons that are too long and off the subject, I am not able to.

Therefore is there anyway to run 2 WHILE loops at the same time? Is there a workaround? 

If I could create a timer using code, then I could delay by a few milliseconds starting one of the WHILE loops and theoretically I could get both  running at the same time. But as far as I know creating a timer cannot be done programatically; it has to be done using XML which the main code doesn't have access to. 

How do I get 2 WHILE loops running at the same time from within the main part of the code?
0 Kudos
2 Replies
brybott
Level 7

Re: Two WHILE loops in the main code?

As far as I know, it's not possible to run multiple while loops at the same time. There are ways to create timing functionality without using the SceneGraph (XML) timer component (try roTimespan). But I would encourage you to figure out a way to make all the business logic fit into one while loop.
0 Kudos
squirreltown
Level 8

Re: Two WHILE loops in the main code?

Make the secondary loop a function instead and put it in the primary loop?
Kinetics Screensavers
0 Kudos