LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Priorities and event handling

My application allows the user to move the cursor a long a two-dimensional color plot. Updating in response to the cursor, it generates two other graphs, each one dimensional. A fairly compute intensive operation.

So I have a problem: on slower machines, the process lags considerably and the graphs may continue updating for several seconds after the user has finished moving the cursor. To help with this, I pulled out the building of graphs into a separate loop, with a Notifier linking the main event loop to the graph building loop. This helps: if things get too far behind, the Notifier remembers only the most recent notification, and the graph building loop acts only on that.

Well, that fixed it mostly. But I still get four or five graph updates after I stop dragging the cursor. Since the information couldn't possibly be stored in the notifier, it must be getting stored in the event queue. Which says that the event loop is not steadily getting priority over the graph building loop.

The documentation says that you can set the relative priorities of loops by putting longer and shorter Wait operations in them. But what about an event loop? It has no Wait operation, it is timed by the Event structure itself.

0 Kudos
Message 1 of 5
(2,830 Views)

One idea.

 

Place the event handeler in a subvi with the execution priority set to "subroutine" This tells the OS to process any threads from this vi with much higher priority and may solve your lagging issues


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(2,810 Views)

Event structures with slide controls often cause problems because they generate hundreds of events which all get queued up.  It sounds as though dragging a cursor may be doing the same thing. Even with your "last notification filter" reducing the number of updates, the event structure will still go through every one of the events.  Search for slide control events to see how others have handled this issue.

 

Lynn

Message 3 of 5
(2,806 Views)

If I remember correctly, the trick was to use dynamically registered events. Once the first is fired, unregister for it while you react to it. The complete code of course went even trickier, so as Lynn suggested, try to dig that thread on the forum (searching for 'dynamically registration of events' might help).

 

Felix

0 Kudos
Message 4 of 5
(2,803 Views)

... and stategic use of the timestamp of the event compbined with the time out event can be used to determine "Are we done yet?"

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 5
(2,801 Views)