Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When I call DisableEventFiring() what events are blocked? All events? On the current item? All events using the current EventReceiver? What happens if two threads change one item and one eventreceiver disables event firing?

(sidenote: in SP2010 DisableEventFiring() is depricated, for SP2010 use: base.eventFiringEnabled = true/false)

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Form MSDN : SPEventReceiverBase.DisableEventFiring Method

Prevents events from being raised.

So someone could think that all events are disabled (all items, all events, all receivers).

But: How DisableEventFiring / EventFiringEnabled works

The setting (DisableEventFiring in 2007 and EventFiringEnabled in 2010) must be for the current event handler; if it was the entire list there’d be all sorts of timing issues and weirdness, and a thousand developers would already have screamed in agony.

And:

This is interesting, as it leads to an interesting scenario – if you were creating additional threads from your Event Receiver’s thread, then event firing will not be disabled on those. I can’t think why you’d want to do that, but there you go.

And one more to verify: Disable event firing in SharePoint when updating a list item outside of an event handler

So i whipped out Reflector and started investigating. Upon disassembling Microsoft.Sharepoint.dll, I discovered that the above mentioned method actually sets a static, thread-specific, property of SPEventManager class called EventFiringDisabled. SPEventManager class is responsible for instantiating event handlers and delivering events to them.

So second thread created from Event receiver will ignore this property.

I even explored sharepoint.dll (14.0.0.0) and I don't see any changes there except obsolete methods.

This all makes sense to me and I can verify this behaviour but only from my memory of past experience because I don't remember screaming about it :) . However I strongly recommend that you preform some tests on your environment just to be sure.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.