LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Static vs Dynamic Events - Some dynamic events are flushed

Solved!
Go to solution

During my project implementation I used Static Events to handle the interface. The Event Structures were in separate while loops in the same vi.

 

I changed the architecture in order to make the code modular and I am using Dynamic Events. The Dynamic Events are captured in Event Structures in separate subVIs. I pass the references of the controls to the subVIs which have the Event Structures and I register the events of the references.

 

The Static Events did not have any problems.

With the Dynamic Events I see that some events are not consumed. Instead, I see in the Event Inspector Window that some times an event is "flushed". That means that the button has to be pressed again.

 

I attach two sample projects which have exactly the same functionality.

The testDemo2 uses Dynamic Events.

The testDemo4 uses Static Events.

 

Which detail do I miss from the Dynamic Events architecture causing it to lose some events?

Download All
0 Kudos
Message 1 of 2
(4,777 Views)
Solution
Accepted by nikosfs

This UI code is crizazy. It's hard to really tell what's going on, but you do have an Unregister for Events VI after your event structure during every single loop and then you re-register at the beginning of each loop. This flushes all dynamic events currently in the event queue and then reregisters again.

 

You should only need to register for events a single time and unregister at the end of the application.

 

What you're doing isn't really very modular. Even if you add a new control/event, you would still need to wire it through the subVI references and register for it, so you're not really saving any time. There's nothing wrong with having static event registration for your user interface. What you probably want is a Queued Message Handler architecture, where your user interface static events create messages that get sent to a consumer loop to handle.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 2
(4,771 Views)