03-28-2013 11:24 AM
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?
Solved! Go to Solution.
03-28-2013 12:06 PM - edited 03-28-2013 12:07 PM
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.
03-28-2013 12:24 PM
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
03-28-2013 12:36 PM
I've been wondering this for a while, but without taking time to investigate. Thanks for sharing.