Announcement

Collapse
No announcement yet.

While loop never stops

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • While loop never stops

    Hi All,

    I did put a while loop in javascript and deployed the channel.
    The channel once started never stops, when I try to stop it in the Dashboard.
    I have to manually stop or restart the Mirth Service.

    For Example: My code has a while loop without a limit...

    while(true){
    Do Some thing.
    }


    Is this the right way to do this?

  • #2
    A while loop will run as long as its condition is true:

    Code:
    while (condition ) {
       DoSomething;
    }
    Since you have 'true' in the condition javascript interprets it as a boolean and the condition is always 'true'

    Comment


    • #3
      You should definitely not have a while(true) loop in JavaScript in a mirth channel. This will hang it, as you have experienced. Try using the JavaScript reader, which will let you execute some task every x number of milliseconds.
      Jacob Brauer
      Director, Software Development
      NextGen Healthcare

      sigpic

      Comment

      Working...
      X