none
will my ItemUpdated Event Receiver run in Synchronous OR in Asynchronous mode if i do not define a <Synchronization> inside the element.xml RRS feed

  • Question

  • I have the following inside my sharepoint 2013 enterprise server:-

    1- using Visual Studio professional 2012 i created a new ItemUpdated Event receiver.

    2- the event receiver will fire after a list item is updated.

    3- the event receiver is scoped at the web level.

    4- here is my Element.xml file:-

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Receivers>
    <Receiver>
    <Name>EventReceiver1ItemUpdated</Name>
    <Type>ItemUpdated</Type>
    <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
    <Class>CreateSubSiteforProjects.EventReceiver1.EventReceiver1</Class>
    <SequenceNumber>10000</SequenceNumber>
    </Receiver>
    </Receivers>
    </Elements>
    But i have noted that my element.xml file is missing the <Synchronization> tag,, and i have already deployed my event receiver.. so can anyone adivce if my ItemUpdate event receiver is executing Synchronous OR Asynchronous? i mean what is the defualt behavior for the ItemUpdated event receiver in sharepoint 2013 when the <Synchronization> tag is not defined?

    Now based on my test the ItemUpdated event receiver , have the following Synchronous behaviors (so not sure if i can be sure that my event receiver is running in Synchronous mode or not):-

    1) i am able to get the user who trigger the event receiver using "properties.CurrentUserId;" and using "properties.Web.CurrentUser.LoginName.ToString()" . while if my event receiver is running in async then i can not reference the user who trigger the event receiver.

    2) also the current event receiver is running under the user permission and not under the system account permission.

    so is my above event receiver running in Synchronous OR in Asynchronous mode? can anyone advice on this please?


    • Edited by johnjohn11 Monday, January 16, 2017 1:50 AM
    Monday, January 16, 2017 1:49 AM

All replies

  • event receiver running in Asynchronous mode
    Monday, January 16, 2017 10:07 AM
  • event receiver running in Asynchronous mode

    but as i know that Asynchronous event receivers have the following main features:-

    1. they run under the "system account" user.

    2. i can not get the current user whose action cause the event receiver to fire.

    but in my case my event receiver have the following:-

    1. it runs under the user whose action caused the event receiver to fire.

    2. i am able to get the current user ID and name as follow: "properties.CurrentUserId;" OR using "properties.Web.CurrentUser.LoginName.ToString()"

    so could still my event receivers is running in async mode while it have the sync mode features ??

    Can you please adivce more on this as i am totally confused?

    Monday, January 16, 2017 11:52 AM
  • Hi John,

    As I understand, by default, all after event receivers were running asynchronously in a different thread and different process.

    But when setting <Synchronization>Synchronous</Synchronization> in element xml, the event would execute synchronously.

    More information:

    Synchronous Event Receivers

    Using synchronous "after" events (e.g. ItemUpdated) in SharePoint 2010

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 17, 2017 5:53 AM
  • Hi John,

    As I understand, by default, all after event receivers were running asynchronously in a different thread and different process.

    But when setting <Synchronization>Synchronous</Synchronization> in element xml, the event would execute synchronously.

    More information:

    Synchronous Event Receivers

    Using synchronous "after" events (e.g. ItemUpdated) in SharePoint 2010

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    but setting the ItemUpdated as Sync using the following tag :-

    <Synchronization>Synchronous</Synchronization>

    will only affect how the ER is being executed internally , so instead of being handled on a new thread (in the Async case), it will be handled on the same thread.. is this correct? while both Sync and Async ERs will provide the same data and properties values ??

    Tuesday, January 17, 2017 11:51 AM
  • Hi join,

    As I understand, it will affect the execute way for the event receiver, it will be changed to a synchronous events and handle it in a same thread.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, January 18, 2017 7:55 AM