4 Replies Latest reply on Jul 24, 2012 6:30 PM by sovain

    implementation / multithreading ?

    sovain

      Hi Everyone,

       

      I am trying to implement the notification module for C# Application. Having read a lot of topics here, I could not find an answer on my simple question.

       

      What I want is to retrieve all Active notifications and make necessary parsing of Interface part with some values accordingly (change colors/flashing etc).

       

      First of all: I do not have any web-service implemented to use a delivery point as WebService.

       

      My question:  Should I implement additional thread in my application and, lets say, every 10 seconds make a request PI System for active notifications and make my actions upon the result ?

       

      Actually, I do not want to go the  way with multithreading. For example, I am using the ActiveView Component for trends and I do not query or refresh anything to get my trends updated, it keeps the connection and works on a background.

       

      It would be fine to have something similar to Notification.

       

      Can I set like a callback / listener  to my function anywhere, so this will be called only when some Notification triggered ?

       

      Can someone give me the idea / article or link to documentation where I can find  similar  solution ?

       

      Thank you for your attention.

       

      Oleg

        • Re: implementation / multithreading ?
          hanyong

          Hi Oleg,

           

          I think the best way to do this, is what you are thinking, to have a background thread working asynchronously to get active notification instances from the server and display the information on your application's UI thread (which I assume is like a Windows Form application).

           

          You can set up callback within your application to update information after you get notification instances. Refer to this article on MSDN. Event though the article assumes you are using to get data from a Web Service, the idea can be applicable in this case.

           

          I think the best way to get active notifications instances is using the ANNotificationList.GetActiveInstances method. You can choose which notifications you want to include in the ANNotificationList object. Here's a code snippet for this:

          // searching for configured notifications from an AF database (afdb)
          AFNamedCollectionList<AFNotification> notifications = AFNotification.FindNotifications(afdb, "*", AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 1000);

          // instantiate ANNotificationList object
          ANNotificationList notiList = new ANNotificationList(notifications);

          // get active instances from the list of notifications
          List<ANNotificationInstances> instances =  notiList.GetActiveInstances();