[SharePoint Developer Tip of the Day] Dealing with SPDeletedConcurrencyException

3 views
Skip to first unread message

Dave Graham

unread,
Mar 5, 2009, 11:52:01 AM3/5/09
to sharepoint-develo...@googlegroups.com

SPDeletedConcurrencyException is an exception thrown by the SPPersistedObject Update() method.  It indicates that another processes has deleted the SPPersistedObject you are trying to update.

The questions you need to answer are:

·         Is this unexpected behavior for your application (is class not expected to be deleted)?

·         Does the removal of my object negatively impact the current operation?

If the answer to both these questions is “no”, then simply suppress this exception.

Building on yesterdays code snip:

int count = 0;
while (true)
{
    try
    {
        MySPPersistedObject obj = FindMyObject(id);
        obj.SomeOperation();
        obj.Update();
        break;
    }
    catch (SPDeletedConcurrencyException){
        // Done. This object is gone so we are finished.
        // Optional logging of condition
        break;
    }
    catch (SPUpdatedConcurrencyException)
    {
        count++;
        if (count > 10)
        {
            throw;
        }
    }
}



--
Posted By Dave Graham to SharePoint Developer Tip of the Day at 3/05/2009 08:50:00 AM
Reply all
Reply to author
Forward
0 new messages