This is a problem that seems to pop up all the time, so I'm wondering if there is an authoritative answer somewhere.
I'm using an event receiver (specifically, the ItemUpdated receiverthrough the "Document Library" list type) in a Page library with publishing enabled. Whenever the publishing status of a page is changed, I want to update a separate list which contains links to certain pages which are going to be displayed on a separate computer.
I do this by deleting all the elements of this list and then adding the ones I want to be there. The problem, however, is that sometimes the ItemUpdated event receiver is called by SharePoint multiple times - perhaps because saving the page, updating the metadata and changing the publishing status all individually trigger the event.
This causes a concurrency problem. Presumably, the list operations I perform happen across multiple database requests, and hence I get the classical situation where the data my code is working on is non-deterministically changed in the middle of a method call.
So the question is, is there some way to limit the ItemUpdated calls to the specific calls I want? Or alternatively, do you have some way to handle these concurrency issues that removes some of the complexity?