Handling SMO Events
There are server event types that can be subscribed to by using an event handler and the ServerConnection object.
Many of the instance classes in SQL Server Management Objects (SMO) can trigger events when certain actions on the server occur.
These events can be handled programmatically by setting up an event handler and subscribing to the associated events. This type of event handling is transient because all the subscriptions are removed when the SMO client program exits.
You handle events by writing an event handler class, creating an instance of it, assigning the event handler to the parent object, and then subscribing to the event.
An event handler class must be written to handle events. The event handler class can contain more than one event handler function, and must be installed for the events to be handled. The event handler functions receive information about the event from the ServerEventNotificatificationArgs parameter that can be used to report information about the event.