in SharePoint 2010

Event Receivers in SharePoint 2010

You might ask what is new with Event Receivers in SharePoint 2010 and you are sure to get an answer that it is now possible to have event receivers for:

  1. List
  2. Workflows

event_receivers

Synchronous and Asynchronous Event Receivers

Now in SP2010, you can configure event receivers to be:

  1. Synchronous
  2. Asynchronous

By default event receivers are asynchronous meaning that they run under the SharePoint timer service (OWSTIMER.exe). This means that the event receivers:

  1. Are not executed immediately, rather it is scheduled to be executed by OWSTIMER.exe.
  2. Don’t run under w3wp.exe process anymore, so when you want to debug your event receivers, you have to attach to OWSTIMER.EXE and wait till they are executed.

However, you can control this behaviour using the Synchronization attribute:

synchronization_attr 

If you set it to Synchronous, then the event receivers run immediately and under the w3wp.exe process. So, if your solution depends on event receivers highly and expect the results immediately, then you have to set it to Synchronous, else setting it to Asynchronous should do the job.

Write a Comment

Comment

Time limit is exhausted. Please reload the CAPTCHA.

  1. Hi Chak, thanks for posting this. It helped me out of an issue.

    I created a new event receiver to handle the WebProvisioned event. The event receiver worked fine when a sub site was manually created, however when a portal site collection was created from Central Admin, it caused a ‘Save conflict’ error due to the event running asynchronously. After reading your post and simply changing the event to run synchronously, this solved the problem.

    Cheers
    Pete

  2. Hi,

    1. I created an event receiver in Visual Studio 2010 and I debugged it by attaching to w3wp.exe process and it worked fine so I guess by default event receivers are synchronous.

    2. When I try to set Synchronization to Asynchronous and deploy it, it throws an error:

    "Error occurred in deployment step ‘Activate Features’: Operation is not valid due to the current state of the object."

    Can you explain me where am I going wrong in both points?