12-21-2011 05:20 AM
I have an Event Structure inside a Do/While Loop. One of the buttons in the event is STOP which stops the do while. The Stop Button itself is inside the event as suggested in the help. My problem is when I hit the stop button everything inside the Do/While runs 1 more time. Other than than the code works perfectly. is this normal behavior for a Do/While ..Event Structure??
12-21-2011 05:36 AM
That's not standard behaviour. It sounds like a race condition or you're reading the value in a bad place. Do you have the Stop control in the Stop:Value Change-event?
/Y
12-21-2011 05:39 AM
All my buttons for each event are in their corresponding event structure and all are set to value change. Any troubleshooting suggestions?? Can you TS a race condition??
12-21-2011 05:50 AM
12-21-2011 06:48 AM
The attached file is the code in a nutshell. I know it can sometimes be diffcult to TS w/o the actual code. Prob is I wrote it in LV2011 on the Lab PC and I have LV2010 at my desk. I don't have internet access in the Lab..of course.
If I hit the OK button 2x's it "does something...does something...build array" then again a second time. The build array is added to with each click of a button in the event structure. If the user hits the STOP it dumps the 2x's worth of data out to excel..except I get 3 rows of data rather than 2...as if the inner loop ran one more time.
Anyways. the only thing that caught my eye is the fact that I don't have a sequence structure around the "build data here" portion of the code. Would that affect how the STOP inside the do while loop is handled??
12-21-2011 07:07 AM
Mark,
According to your code, and ignoring the fact that the outer while loop is pointless (it can only run once, so why have it?), I can see that due flat sequence structure is forcing the "Do Something" elements to occur after the event structure. Therefore, when the Stop button is pressed, the event structure completes with some True values for the while loop conditional terminals, and then the subsequent frames of the sequence will execute (although from this code it would make no difference to the output array size).
If you need the code to exit without performing more work when the user presses Stop, put the Event structure in the last frame of the flat sequence structure.
12-21-2011 08:05 AM
Thanks..I'll give that a shot.
12-22-2011 12:29 AM
Here's another option.
Check out the Producer/Consumer design pattern.
Attached is a modified version of the "Producer/Consumer Design Pattern (Events)" template vi (LV2010).
It's fairly easy to modify for your specific needs.
steve
12-22-2011 01:25 AM - edited 12-22-2011 01:33 AM
i agree with Thoric...
removing the event from your sequence structure will help i feel...
12-22-2011 04:37 AM
Thanks for taking the time to do that.. I started to look at consumer/producer..Someone had mention queuing.