AnsweredAssumed Answered

Check in an AF Database Asynchronously from AF SDK

Question asked by hmokdad on May 5, 2017
Latest reply on May 9, 2017 by cmanhard

Hi,

We have an application that creates a big number of event frames based on a certain logic that for some reason we couldn't use PI Analytics and had to write our own application using AF SDK. We have  a thread that is creating event frames and adding them to the In-Memory AF database and another thread periodically checking in the AF Database.

Thread1 (Creating Event Frames):

                 AFEventFrame myEventFrame = new AFEventFrame(AFDatabase, myEventFrameName, myEFTemplate);

                myEventFrame.SetStartTime(DateTime.Now);

                myEventFrame.SetEndTime(DateTime.Now);

                myEventFrame.ReferencedElements.Add(myAFElement);

 

Thread2 (Periodically Checking in the database):

            while (true)

            {

                if (AFDatabase.HasItemsCheckedOutToMe)

                {

                    AFDatabase.CheckIn(AFCheckedOutMode.ObjectsCheckedOutThisSession);

                }

                System.Threading.Thread.Sleep(10000);

            }

 

Now the problem is when the AF Database is being checked in, it is getting locked (The AFDatabase object), and thus Thread1 is blocked till the Checkin is complete, causing us a delay that accumulates over time. Is there a way to asynchronously check in the database? We were checking an alternative to write the event frames directly into SQL (PIFD) database but this is the last thing we want to do.

 

Thanks for your help

Outcomes