AnsweredAssumed Answered

Search and retrieve AF database asynchronously

Question asked by elia-acc on Dec 11, 2017
Latest reply on Dec 11, 2017 by tramachandran


I'm building an application which need to synchronize an AF database with external systems.

As it is an ASP.NET application I need to be as keen as possible with the thread pool; especially it would be better to free up the thread before invoking I/O –bound operations.

Nowadays, this is done via the async/await framework (like StreamReader.ReadToEndAsync).

I saw that OsiSoft made improvements on that topic for the “point data” retrieval part.


Unfortunately there is no such approach for simple element search and I’m wondering what would be the best implementation of the following method :

public async Task<IEnumerable<Guid>> GetElementsByTemplateAsync(string templateName)


    AFSearchToken templateToken = new AFSearchToken(AFSearchFilter.TemplateName, AFSearchOperator.Equal, templateName);

    AFSearchToken allDescendants = new AFSearchToken(AFSearchFilter.AllDescendants, AFSearchOperator.Equal, Boolean.TrueString);

    AFElementSearch elementSearch = new AFElementSearch(_piAfDatabase, nameof(GetEquipmentAfIdsByTemplate), new[]{templateToken, allDescendants});

    IEnumerable<Guid> returnVAlue =  elementSearch.FindObjectIds();

    return returnValue;