Nested Document Locks Outside of Command Context

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Suppose I have many helper functions which are called outside the context of a Command. Within these functions, I lock the active document (Document.LockDocument() no parameters). Often these helper functions are called from higher level functions, currently resulting in the document being Locked/Unlocked hundreds or thousands of times in seconds. If I lock the document in the calling function, does this result in the locks in the lower level functions being 'nested' so that the document is only locked/unlocked once? I have tried locking at a higher level, and there are no discernible problems. Note that the DocumentLockModeChanged event is firing each time Document.LockDocument is called, and when the DocumentLock object is disposed. This seems to indicate that locking the document in the calling function does not have the desired effect. But I want to be certain before refactoring.
I would like to leave the code for locking the document in the helper functions if possible, because they are called in a variety of contexts and refactoring my code to lock the document before they are called in every instance would be quite time consuming.
Thanks,
Kevin