1 Reply Latest reply on Apr 11, 2014 5:38 PM by tinklerj

    Using EventPipe.TakeAll() in C#

    tinklerj

      I can't get the following to work (note I have omitted the code that gets the EventPipe from a PointList.Data):

       
      EventPipe evtPipe;     
      // ... omit getting event pipe from a PointList.Data 
      PIEventObject[] eventsRetrieved;
      // Get runtime InvalidCastException: Unable to cast object of type 'System.Object[]' to type 'PISDK.PIEventObject[]'.
      eventsRetrieved = (PIEventObject[])evtPipe.TakeAll();
      

      What's wrong with that cast?

       

      And on a similar subject:

       

      When I have finished with the event pipe I want it to stop getting events.  If I just set the variable evtPipe to null will that do it?  If not, how?

        • Re: Using EventPipe.TakeAll() in C#
          tinklerj

          OK I found out how to do it:

           

           

           
          EventPipe evtPipe;     
          // ... omit getting event pipe from a PointList.Data 
          PIEventObject[] eventsRetrieved;
          // Get runtime InvalidcastException: Unable to cast object of type 'System.Object[]' to type 'PISDK.PIEventObject[]'.
          System.Array objects = evtPipe.TakeAll();
          foreach (object obj in objects)
          {
              PIEventObject thisEvent = (PIEventObject)obj;
               // Can process object now
          }
          

           Would still like an answer to the question about how to stop the pipe retrieving events.