I'm trying to update an item when it is added to a document library. I have an EventReceiver on my document library and I am using the
ItemAdded event. I am using the New Document button to create a Word doc.
I click save in word, and after the save is complete, my
ItemAdded event triggers and runs the following.
listItem["Field"] = value; listItem.SystemUpdate(false);
I get an error message stating:
The file <url> is locked for share use by <user>.
This lock seems to persist until the file is closed in Word.
I found SPLockType in the MSDN which states.
The file is locked for editing by one or more users. Any of these users can save the file if the correct lock identifier is specified. Other users are prevented from saving the file until the lock is released.
Which makes me think I should be able to do this if I can specify the lock id, but I don't know how to do that.
Otherwise, is there a way to delay my code from running until the lock is released? I don't see any methods on
SPItemEventReceiver that appear to apply.