Entradas

Mostrando entradas de mayo, 2020

Slider ghost events and how to avoid them

Imagen
One typical UI problem a LabVIEW developer faces is how to prevent an oversupply of events generated by some front panel objects, particularly sliders and knobs. When the user drags the slider, a lot of events with slightly different associated values pile up waiting to be processed. So if each event entails a complex code execution or communication with some equipment, we are wasting time and resources with this "ghost events". As you may know, this is an old problem and any search on NI forums will uncover several workarounds . In my experience, the best approach is to validate the event before processing it. But how? As in the image above, first wait a length of time and then check if the event associated value is still the value in the control. If not, discard (because the final value is still waiting). Sounds simple but some considerations are required: First, the milliseconds to wait (500 in this example) will both filter a higher number of unnecessary events an