04-04-2011 07:05 AM
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.
04-04-2011 08:43 AM
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
04-04-2011 08:55 AM
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
04-04-2011 09:00 AM
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
04-04-2011 09:01 AM
... 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