10-27-2008 12:41 PM
10-27-2008 12:42 PM
10-27-2008 12:45 PM
It also sounds as though your array may be growing with each pass through the -1 state. If so this will almost certainly cause a slowdown and eventual out of memory error for your program.
Events and producer/consumer are definitely the way to go.
Lynn
10-27-2008 01:02 PM
Haha, I thought of that right after I first posted. That is, I thought of the time it takes to build a new array each time, so I changed the code to insert array elements instead. I no longer build the array. I took care of that in my 'nuts and bolts' case, but it didn't occur to me until now to fix it on the -1 case.
10-27-2008 01:12 PM
10-27-2008 01:13 PM
Insert into Array also increases the size of the array so it has the same memory allocation problems that Build Array has.
A fixed size array with Replace Array Element would not have the problem. You initialize the array outside the loop to a size greater than the maximum number of element you ever expect to accumulate before you have used them. Then inside the loop use Replace Array Element to put new data into the array. After searching for the new data, Replace it again with the default value.
A queue might be better choices than an array. They can also have fixed sizes (set at creation) and have useful features like timeout and error clusters.
Lynn
10-27-2008 01:31 PM