What is Event Recursion in SharePoint 2010? How to avoid it?

Event recursion or Event handler recursion is a problem which occurs in event receiver. Event recursion will update your item again and again. Event recursion is a reason for poor performance of SharePoint site.

How to Avoid Event Recursion

When working with event receivers, there is always a chance that your code will trigger the same event multiple time. As a result, the application pool will be recycled, which will be a poor performance by SharePoint Site.
To avoid this issue use EventFiringEnabled property which is exposed by the SPEventProperties base class and is available within event receivers.
You should set false and true before updating an item and after updating that item respectively.

Below is the code to avoid Event Recursion

 public override void ItemUpdating(SPItemEventProperties properties)
                EventFiringEnabled = false;
                //Update item                
                EventFiringEnabled = true; 

Share on Google Plus

Please write your comment below. Share this blog on Social media.


Post a Comment

Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks