Dave,
Here is some code. I tried to strip out all the custom classes and dependencies specific to my usage. What's left I beleive may be helpful to you. I used ideas and code snipits from reading other posts on events. Another specific contributor that is notable is arcticad and his reply on "Document Change Event".
Good luck.
{code}
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Public Class AppEventsClass
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Private mIdCol As List(Of ObjectId) 'a collection of ObjectId's for use in the command ended event handler
Private DocMan As DocumentCollection
Private db As Database
Private doc As Document
Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
mIdCol = New List(Of ObjectId)
DocMan = Application.DocumentManager
AddHandler DocMan.DocumentCreated, AddressOf callback_documentCreated
initEvents()
End Sub
Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
RemoveHandler DocMan.DocumentCreated, AddressOf callback_documentCreated
RemoveHandler doc.CommandEnded, AddressOf callback_CommandEnded
RemoveHandler db.ObjectModified, AddressOf callback_ObjectModified
mIdCol.Clear()
End Sub
Private Sub initEvents()
For Each doc In DocMan
db = doc.Database
AddHandler doc.CommandEnded, AddressOf callback_CommandEnded
AddHandler db.ObjectModified, AddressOf callback_ObjectModified
Next
End Sub
Private Sub callback_documentCreated(ByVal sender As Object, ByVal e As DocumentCollectionEventArgs)
initEvents()
End Sub
Private Sub callback_CommandEnded(ByVal sender As Object, ByVal e As CommandEventArgs)
If mSIdCol.Count > 0 Then
Dim ObjID As ObjectId
For Each ObjID In mIdCol
Dim Struct As New cStructure(ObjID)
Struct.Rebuild()
Struct = Nothing
Next
mIdCol.Clear()
End If
End Sub
Private Sub callback_ObjectModified(ByVal sender As Object, ByVal e As ObjectEventArgs)
If Not mIdCol.Contains(e.DBObject.Id) Then
mIdCol.Add(e.DBObject.Id)
End If
End Sub
End Class
{code)