04-06-2017 09:33 AM
When unregistering for user events, should I put the unregister after the event structure (like the bottom structure below) or can I put the unregister inside the event structure itself (like the top structure below)? My (limited) testing seems to show that the putting the unregister inside the event structure works like I expect, but I want to make sure I'm not shooting myself in the foot later on. All the examples I've seen show the unregister after, but I'd prefer to have it inside due to the way I've structured my error handling if it isn't going to cause me problems
04-06-2017 10:14 AM
Should not matter either way assuming that event case stops your loop the Event Structure is in.
04-06-2017 11:02 AM
Most of the time, an event structure is put inside a While loop. Is that going to be the case here?
If the event structure is the only thing in the While loop, I don't think it matters either way.
However, if the entire code shown is inside the loop, there may be split seconds where the event isn't registered (since it creates a new registration each loop). Also, it puts a new registration into memory each loop, and while the second one closes it, the first one leaves it open.
04-06-2017 11:14 AM
I think if the event registration is connected to shift register in the while it should not change, even if it is not connected to a shift register is should not change.
mcduff
04-06-2017 03:41 PM
My preference is on the outside of the loop. My thoughts are that this makes the flow of operations look like normal G code. Init, Work, Close. If you are closing in your 'work' section of your code, then a quick glance at the code might have it look like you aren't performing cleanup properly, and I may need to look through all of you cases to make sure you are. Functionally I'd say you don't have an issue here either way.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
04-06-2017 06:40 PM
I have always closed outside the loop (since all the examples show this), however, closing inside of the loop appeals to me for the following reasons:
mcduff