Hi we can Change an Asynchronous Eventhandler to Synchronous Eventhandler in lists Sharepoint 2010 in two ways to avoid save conflict error.

First method:

In the elements.xml file just change the name of list and add synchronous tag

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
<Receivers ListUrl=”ListName”>
<Receiver>
<Name>EventReceiver1ItemAdded</Name>
<Type>ItemAdded</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>EventReceiverProject1.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>1000</SequenceNumber>
<Synchronization>Synchronous</Synchronization>

</Receiver>
</Receivers>
</Elements>

Second method:

//Create an Empty Eventhandler

 SPEventReceiverDefinition itemAddedEventRec = lstname.EventReceivers.Add();

itemAddedEventRec.Name = “AddItem”;

//Change to Synchronous

itemAddedEventRec.Synchronization = SPEventReceiverSynchronization.Synchronous;

itemAddedEventRec.Type = SPEventReceiverType.ItemAdded;

itemAddedEventRec.Assembly = “Assembly Name”;

itemAddedEventRec.Class = “ClassName”;

itemAddedEventRec.Update();

lstname.Update();

Advertisements