We have a SharePoint 2010 On-Prem solution.
I have an ItemAdded event receiver which has been made synchronous using the Synchronization property. Now, when this event receiver fires, I have used the properties.Web property to get a reference to the current web as per guidance here: http://blogs.msdn.com/b/rogerla/archive/2009/11/30/sharepoin… .
Now when this event receiver fires, the ULS logs report the dreaded "An SPRequest object was not disposed before the end of this thread" error. Since the properties.Web is managed by SharePoint, I have not disposed it explicitly in my code. But, if I do a properties.Dispose() at the end of my code, then the error is no longer reported.
The funny thing is, If I make the eventreceiver async, the error does not show up at all.
That means a weird race condition is developing where if the event receiver is synchronous, properties.Web is somehow not disposed before the thread ends(?) and the error is logged in ULS.
Has anybody seen this kind of behavior before? I could potentially do a properties.Dispose() at the end of my code but I am not sure what the impact will be as all the guidance states you do not need to dispose objects owned by SharePoint.