LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When is a User Event discarded from Register?

Solved!
Go to solution

Howdy--

 

Guys, I think I'm just shy of understanding something about User Events here, but I could use a little push.  In a nutshell, I need to make sure that multiple consumers respond to an event, even if the Event was fired before some of the consumers' Event Structures begin to execute.  Attached are all the permutations of the basic idea I could think of.  I know that "Case 5" is guaranteed to work if I create the individual Registers before the Event is fired, but it bothers me that I don't understand exactly why "Case 4" does not work, while all of the others do.  My initial understanding of User Event Registration had me thinking that "Case 4" and "Case 3" would be identical...i.e. one of the Structures dequeues the Event from the Register, leaving the other looking at an empty queue.  Why is "Case 4" the only one that fails?

 

 

Case 2.pngCase 3.pngCase 1.png

 

 

 

 

 

 

 

 

Case 4.pngCase 5.pngCase 6.png

0 Kudos
Message 1 of 4
(2,937 Views)
Solution
Accepted by topic author BradNC

There are two separate issues here. The first is that you have a race condition. There's nothing guaranteeing that the registration will happen before the event is generated (although presumably the trigger is the value change for the control and it takes you a long time to press it). The code should be changed so that the registration happens before.

 

The second issue is that you're using the same event registration refnum for two event structures. This is an easy mistake to make, but it's also a very big one. An event registration refnum should NEVER EVER EVER go to more than one event structure. If it does, you will find yourself running into all kinds of weird bugs (such as the one you're seeing where something which seemingly should not affect how they behave does affect them). There's a caveats section in the LV help which talks about this, but it's easy to miss and not as explicit as I am.

 

The correct way to do this is to have two separate registration nodes.


___________________
Try to take over the world!
Message 2 of 4
(2,920 Views)

Thanks, tst, for weighing in on that.  I did go and find that events caveats help page you mention just now.  I get the idea at least enough to move forward now.  I think it was bugging me most that so many of the incorrect cases seem to work in my tests...the worst kind of bugs are the "sometimes bugs" I suppose.

 

By the way, the first issue you was indeed just sloppiness on my part...I was simply highlighting execution and making sure the event registered before I pushed the Stop button.

 

Anyhow, very good lesson learned here.  Thanks again for the help.

 

--Brad

0 Kudos
Message 3 of 4
(2,905 Views)

I've been wondering this for a while, but without taking time to investigate. Thanks for sharing. Smiley LOL

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 4 of 4
(2,898 Views)