Showing results for 
Search instead for 
Did you mean: 

dynamic event registration only works for 2 inputs??


I have written a routine that traverses for GObjects when the user runs the VI.  Based on some information contained within the label of the control, the routine puts a reference to the control in one of 4 arrays.  I dynamically register these 4 arrays as part of an event structure.


What I'm finding though is that only objects within the first 2 arrays (rw_event_array and wtc_event_array) ever trigger the event structure.  I have used the probes and breakpoints to verify that the other 2 arrays (wo_event_array and other_event_array) both are full of references, yet they never trigger the event.


As a specific example, I have a control that is of type wo.  I stepped through my code and saw a reference to the object stored in the "other_event_array" variable.  I put a breakpoint on the event structure (which is triggered by a value change on the boolean control), yet it's never triggered.


Why would it be working for 2 of the arrays I input, and not the other 2?


A couple screen's the place where the arrays are built:



Here's where they are registered:




Just to be clear - it's not that the code inside the event structure "isn't working"'s that the code inside the event structure is never executed.  The breakpoint you see surrounding the event structure never triggers.  And again, the first two arrays (rw and wtc) reliably trigger the event structure.



0 Kudos
Message 1 of 4

It's very hard to tell from your limited screenshots where the problem might be. Is there any chance you could upload the VIs instead?


Why are you using local variables for the array references? Given that you must find all the references before you register for events on them, those should be wires. Otherwise there's a possibility of a race condition - the events could be registered before the arrays are filled. That's my best guess as to the problem. You wrote that you probed the array wire and confirmed that there are values in it, but did you probe the wire going into the Register for Events, or only the wire going into the array indicator?


Have you checked if there are any error from the Register for Events node?

0 Kudos
Message 2 of 4

I know it's not a race condition because I use a flat sequence structure to separate the population of the array from when I register the events.


You hit on something else the time since my post, I hooked up an error indicator to the registration and saw an error 1055 (object reference invalid), so I'm researching that now.  It must be that all of the object refs within those 2 arrays are invalid and that's why it's never triggered.  I will continue investigating.  Thanks for the help...

0 Kudos
Message 3 of 4

@bmishoe wrote:

I know it's not a race condition because I use a flat sequence structure to separate the population of the array from when I register the events.

While the sequence structure will solve the potential race condition, it would still be better LabVIEW style to eliminate the local variables and use wires instead. The use of sequence structures is generally discouraged; use wires and dataflow to determine the order of execution instead.

0 Kudos
Message 4 of 4