doc.CloseAndDiscard(); call negate the requirement to Dispose the DocumentLock Object. ??
Regards,
Title: Re: Disposing of DocumentLock Object
Post by: It's Alive! on July 06, 2022, 06:19:38 AM
I don’t think DocumentLock actually locks the database, I think it just prevents execution contexts It’s not an AcDbObject, so I’m pretty sure that letting the garbage collector handle it is safe, Dispose only calls its destructor
BTW, doc.CloseAndDiscard(); calls the COM version of Document.close with the false parameter.
Also an FYI "The document does not need to be locked to open an AcDbObject in AcDb::kForRead, nor to get system variables." according to the docs
Title: Re: Disposing of DocumentLock Object
Post by: kdub_nz on July 06, 2022, 05:40:21 PM
Thanks Daniel, that's something to chew on.
The code I was looking at was changing Layer names in a side doc. It just had
It was being called from a Form, iterating over a list of selected drawings. . . . a little buzzer went off in my brain when I saw the LockDocument() was not disposed.