Go to content Go to navigation

Please no WAIT_UNTIL

26 April 2008, 07:51 by Chad Reynoldson

The netlinx statement WAIT_UNTIL is often mis-used by new programmers. Program execution does not halt at that point in the code, rather it is put in a list and reviewed for expiration after each pass of mainline. At first it seems like a good idea, but in practice it creates hard to find bugs, especially when it is not understood or implemented correctly.

I had recently taken on support of a project written by a new netlinx programmer. The code was riddled with WAIT_UNTIL (nProjPwr) statements. The various intentions included: setting the projector input after power on, routing the source after projector power on, setting feedback on a button after projector power on.

The inherited code displayed many poor user experiences and things seemed to take a long time to occur after button presses. The most glaring problem was not allowing the source selection until the projector turned on. There was no reason to delay the switcher execution until the projector turned on, this was bad implementation.

My recommendation with WAIT_UNTIL is to not use it. You should learn to embrace the repeating mainline and not fight it. If you think you must use WAIT_UNTIL, you should name it and cancel any other that may be pending for the same context.

CANCEL_WAIT_UNTIL 'PROJ ON DELAY'
WAIT_UNTIL (nProjPwr) 'PROJ ON DELAY'
{
// Do stuff here.
}

Share This Article

Comments

Comments are turned off for this article.