Recommended error trapping/handling when using Event Pipes (IEventPipe2)

Discussion created by deonpienaar on May 31, 2010
Latest reply on Jun 7, 2010 by deonpienaar

Good day,


We're building a few proof-of-concepts involving periodic or on-event data retrievals from PI.  Immediately working with using event pipes, I see a possible problem regarding error handling and recovery (such as internal SDK errors, disconnected from server, error with polling etc).


To be clear: signing up for updates will only happen during initialization, so we don't have to worry about adding/removing more points for signup.  _pipe.RemoveSignUp() is called upon termination (if _pipe!=null). 
What are the recommended errors to trap for during initilization, the OnNewValue event and generally checking when the event pipe has failed? Can the event pipe be reinitialized or should all objects be made NULL and re-created.


Also, during the OnNewValue event, would it be beneficial to attempt the 'Using' block to assit with memory manayement?  (For example, the code below uses the System.Array object.  I could inherit it and attempt to implement the iDisposable interface and dispose the related objects)

Thanks in advance, below is a summary of the code in use:

Property Declarations

//SDK connection
PISDK.Server _server;
PointList ptlist = new PointList();

PISDK._DEventPipeEvents_Event _ptEvent;
IEventPipe2 _pipe;



//add points to pointlist
_pipe = (IEventPipe2)ptlist.Data.EventPipe;
_ptEvent = (_DEventPipeEvents_Event)_pipe;
_ptEvent.OnNewValue += new _DEventPipeEvents_OnNewValueEventHandler(_ptEvent_OnNewValue);


On new value Event handling

private void _ptEvent_OnNewValue()
 Array tmpArray = _pipe.TakeAll();
 foreach (Object obj in tmpArray)
  //handle values