2 Replies Latest reply on Oct 15, 2015 9:06 PM by mdspath

    AFValues out of scope?

    mdspath

      Hello:

      The attached is a pic of code that has been stripped so it will not compile but hopefully enough to give someone the flow of the code. What is happening is we are iterating through the vesselBatchIds IEnum the second time we are getting a crash error "cannot access disposed object" message.

      pointsValues does not go out of scope.

      Is there a limit on how many time to iterate through AFValues?

       

      foreach (BatchDetails bd in vesselBatchIds)

                      {

                          foreach (AFValues Vals in pointsValues)

                          {

        • Re: AFValues out of scope?
          Mike Zboray

          You can only iterate the enumerables returned from some AFSDK bulk calls once. This applies to many of the calls on AFData, AFListData, and PIPointList like GetRecordedValues.

           

          I reported this as defect to the AF team some time ago and I was informed that this is "as designed" and has been documented as the behavior.

           

          The workaround is to read the enumerable into a List or array (use LINQ's ToList or ToArray) and iterate that multiple times.