Problem:
I have a document library with an "ItemUpdated" item eventreceiver. Each time I upload a document, the eventreceiver fired 2 times in two different threads, with update conflicts as a concequens.
Cause:
When you use check-in/check-out on your document libraries the check-in action also fires an ItemUpdated event. If found this information here (good article!):
Solution:
We need to check which "ItemUpdated" we deal with ... the one from the check-in or the 'real' one. If found this code on the MS site to check the source of the event:
if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
{
//This is when the update event is triggered by
check-in.
}
else
{
//This is triggered by events other than check-in
action.
}