Asle Frantzen

Time consuming operation when getting instances for my ANNotificationList

Discussion created by Asle Frantzen Champion on Oct 10, 2012
Latest reply on Mar 16, 2016 by Mike Zboray

I've read through some threads about this topic but haven't found what I'm looking for.


I need to get instances for my ANNotificationList object, but what used to be a quick loading time on my test system has now evolved into something which takes between 20 and 120 seconds. I used the GetInstances(TimeRange) function, but I read that GetActiveInstances() would be better so I switched to that. Still I didn't experience any performance improvement, so I tried a few of the other ways of getting the instances - like GetLastInstances().


There are 272 notifications in place today, although they're all disabled for the moment. While using the GetInstances(TimeRange) and the GetLastInstances() functions I get all the 272 instances back, and have to check the instances.Count to see if there are any with history. The GetActiveInstances() only returns 1, and this sounds like the best way to do this.


But my problem is that all these ways of getting the instances take the same time to execute. I would expect shorter time when only getting one instance back, compared to getting them all. Am I doing something wrong here? Could there be something related to the fact that my notifications are disabled at the moment?




A bit of code:

notificationList = new ANNotificationList(AFNotification.FindNotifications(myPIDB, null, AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 1000));
// Retrieve the history
if (Logging == "YES") log.WriteEntry("Time before getting notification instances: " + DateTime.Now.ToString());
List notificationInstances = notificationList.GetActiveInstances();
if (Logging == "YES") log.WriteEntry(notificationInstances.Count.ToString() + " instances found, at: " + DateTime.Now.ToString());