Alexander, the solution you point to is the one I referred to in my original post. I tried running the posts through Googles translator but only understood about half.
I do lock the document at the beginning of the function.
Document ThisDrawing = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
ThisDrawing.LockDocument();
Then at the end of the function.
ThisDrawing.LockDocument(DocumentLockMode.NotLocked, string.Empty, string.Empty, false);
I have also tried this at the beginning:
Document ThisDrawing = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
DocumentLock dLock = ThisDrawing.LockDocument();
And this at the end:
dLock.Dispose();
I guess this question is now "How do you UnLock a Locked document?"