Esempio n. 1
0
 public async Task AsyncTask_updateinfo()
 {
     IList <PIPointChangeInfo> clist = new List <PIPointChangeInfo>();
     Action asyncJobupdateinfo       = () =>
     {
         PIPointChangesCookie cookie = null;
         while (updateval2 == 0)
         {
             if (myPIServer != null)
             {
                 if (monitval == 0)
                 {
                     monitval = 1;
                     cookie   = null;
                     UpdMonitorLabel("Monitoring ON (" + myPIServer.Name + ")");
                 }
                 if (ReferenceEquals(cookie, null))
                 {
                     clist = myPIServer.FindChangedPIPoints(int.MaxValue, null, out cookie);
                 }
                 else
                 {
                     clist = myPIServer.FindChangedPIPoints(int.MaxValue, cookie, out cookie);
                 }
                 if (clist != null)
                 {
                     foreach (PIPointChangeInfo change in clist)
                     {
                         //MessageBox.Show(change.ID + " : " + change.Action);
                         string[] displayvalues = new string[3];
                         if (change.Action.ToString() == "Removed")
                         {
                             displayvalues[0] = change.ID.ToString();
                         }
                         else
                         {
                             PIPoint mypt = PIPoint.FindPIPoint(myPIServer, change.ID);
                             displayvalues[0] = mypt.Name;
                         }
                         displayvalues[1] = change.Action.ToString();
                         displayvalues[2] = DateTime.Now.ToString();
                         ListViewItem lvi = new ListViewItem(displayvalues);
                         UpdListView2(lvi);
                     }
                 }
             }
         }
     };
     await Task.Run(asyncJobupdateinfo);
 }