10-29-2018 05:45 PM
I thought I'd come up with a nice method for inter-process communication, but what I've got is very flaky, making me suspect a race condition. When you run the VI and repeatedly press the GetMeasurement button, sometimes it works (displays a new value) and sometimes it doesn't. I put a probe on the UI loop's "UI_Command" data and it doesn't update every time. So the dynamic event is not always being "received" by the UI loop? Any ideas out there? Am I ridiculously abusing events for this purpose? thanks much, paul
Solved! Go to Solution.
10-29-2018 05:51 PM
You cannot split the Reg Events wire, use one for each loop. See below.
mcduff
10-29-2018 06:16 PM - edited 10-29-2018 06:18 PM
mcduff is absolutely right, I just wanted to add a little bit about what registering for events does.
When you work with queues there is a single queue reference which the sender uses to send data, and the receiver uses to receive data. Multiple senders is fine if you don't care about the order the data is received, so we can use queues with N senders and 1 receiver, also called N:1 messaging. You never want to dequeue elements from a queue in multiple places at the same time, because only one of them can get the element.
When you work with events, you get two references. The event reference is used by the sender to send data, and the event registration is used by receiver to receive data. For the same reason you don't want to dequeue from a queue at multiple places, you also don't want to receive events from the same event registration in multiple places. However, if you create multiple event registrations, you will have no problem receiving the event data in multiple places. This could be used for N:N messaging, but usually the event is triggered by a specific module or process in your code, so it tends to be used for 1:N messaging.
If you handle a single event registration in two event structures that have an equal chance at grabbing it, then it will sometimes be handled by both, and sometimes by only 1. If you fire the event N times, it will be handled between N and 2N times total, but not in any repeatable way. In this way, it is a little bit different than dequeueing from a queue in multiple places, because then each element can only be dequeued once.
10-29-2018 06:30 PM
Thanks for the explanation!
10-29-2018 07:52 PM
Ahhh, that makes sense. Will try & fix tonight. Thanks to both of you? paul
10-29-2018 07:58 PM
Works like a champ with separate refnums - I do appreciate the help, guys!