06-16-2019 01:31 PM
During the development of an asynchronous framework which makes extensive use of User Events, I thought I would test the functionality of the 'Destroy User Event' function using the VI attached. With LabVIEW 2018 (SP1) on Windows 10, I see that the event is received by the Event Structure even though the User Event Reference has been destroyed. This would appear to be contrary to the documentation which states that Any Event structures registered for this user event no longer receive the event.
The observed behaviour seems to be both logical and desirable from an encapsulation point of view - If the generator of an event is also the owner of the User Event Reference then the generator can safely destroy the User Event Reference once it has sent it's event "message" and each receiver of the event message only has to destroy their own event registration.
My only concern is that this is not what the documentation is alluding to. Am I missing something in my understanding of the documentation or have I made some mistake with my test VI? I would be interested in hearing the opinions of others on this topic.
06-16-2019 02:17 PM
Don't have LabVIEW here, and a bit hard to describe, but I will try.
Hopefully this makes sense.
mcduff
06-16-2019 03:14 PM
Hi mcduff
Thanks for your comment - you description here exactly follows my understanding of what is going on. My question (which I somewhat buried in my post) is:
What does the NI documentation on the Destroy User Event function mean when it says " Any Event structures registered for this user event no longer receive the event"?
It doesn't seem to make sense and my fear is that the operation of the function is changed in the future so it does some global destruction of any 'recieve' event associated with the User Event Reference as per the documentation.
Cheers
John
06-16-2019 03:15 PM - edited 06-16-2019 03:17 PM
<duplicate>
06-16-2019 03:17 PM
@mcduff wrote:
Hopefully this makes sense.
Well, it didn't quite make sense, but I think I know what you were trying to say, so I'll "play Professor" and paraphrase (but the ideas and basic credit goes to mcduff!):
I've used User Events, but haven't tried doing the "intermediate" creation/destruction of Event components mid-stream, so have not had mcduff's experience (nor knowledge) of the details and timing of the Event process. In particular, I think his explanation of a separate "writer" (User Events) and "reader" (Event Registration Refnum) data container nicely encapsulates a good way to understand some of the "interesting features" of the Event Loop and User Events.
Bob Schor
06-16-2019 03:21 PM
Usually NI does not change functionality.
When you destroy the User Event, you are destroying the "mailman" who carries the "letters" to the "mailbox (Register User Events)". You destroyed the mailman, but not the mailbox. The mailbox is still there, it is just that there are no mailmen to deliver letters, so you mailbox will remain empty. (I think this is what NI means, anybody that has a mailbox for these letters can no longer receive them.)
You destroy the mailbox after the event structure.
mcduff
06-16-2019 04:22 PM
@mcduff wrote:
Usually NI does not change functionality.
When you destroy the User Event, you are destroying the "mailman" who carries the "letters" to the "mailbox (Register User Events)". You destroyed the mailman, but not the mailbox. The mailbox is still there, it is just that there are no mailmen to deliver letters, so you mailbox will remain empty.
If you've delivered a dozen letters before the HomeOwner looked in the Mailbox, then killed the mailman, wouldn't there still be letters in the Mailbox? [I should do the Experiment, but I hope the answer is "Yes" ...]
Bob Schor
06-16-2019 04:33 PM
"No longer receive" isn't the same as "deletes all events received."
If the event was received before you killed the user event, it's still there. Are you seeing any that were sent after you ended the user event still get sent?
06-16-2019 04:43 PM
Oops, forgot to push "Post" before I wrote the Test Code (which, fortunately, proved my assertion):
I create 12 User Events (0 .. 11), then Register for them (so they should be "lost", then register 12 more (12 .. 23). In the Event Loop, I save every Event I see (stopping when/if I see "23") and hope I see 12-23 (and I do ...).
Bob Schor
06-16-2019 05:22 PM
The documentation for Events tries too hard to simplify things by skipping over the Event-Registration queues that are actually the central important concept. Personally, I think this makes Events harder to grasp. You shouldn't worry about the behaviour changing.