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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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
Roku Guru

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
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.