AnsweredAssumed Answered

Attribute.PIPoint performance issues

Question asked by GeethaDean on Mar 9, 2015
Latest reply on Mar 10, 2015 by rdavin

I am trying to detect whether or not an AF Attribute has a PIPoint associated with it using the following code:

 

foreach(AFAttribute attribute in element.Attributes){
     try{
          if(attribute.PIPoint != null){                   // This line is slow
               string pitag_name = attribute.PIPoint.Name; // This line is slow
          }
     } catch (Exception e) {
          // Handle error thrown when no PIPoint exists
     }
}

The problem here is twofold. One is that this method of detecting a PIPoint's existence takes 2-3 seconds. Then reading the name by calling the Attribute.PIPoint.Name property takes 2-3 seconds. And further annoyance is caused by having to use a try/catch to catch the error that is thrown when a PIPoint does not exist.

 

My main issue is performance. This has to be done quickly and, if possible, more neatly (i.e. without the try/catch). Is there a better way to do this?

Outcomes