The most general way to handle PISDK events is by using Event objects, which are objects whose only purpose is to raise events.
Every PISDK object that can raise events has an Events property which returns an Event object of an appropriate type. For example, the Servers collections Events property returns a ServersEvents object, while a PIGroup objects Events property returns a PIGroupEvents object.
To handle the events that an Events object raises, you must store a reference to that object into an object variable that was declared using the WithEvents keyword. See the example.