SPUpdatedConcurrencyException is an exception thrown by the SPPersistedObject Update() method. It indicates that another processes has updated the SPPersistedObject you have just modified and are trying to update.
I have found that best practice is to wrap all calls to Update on any SPPersistedObject to iterate until successful. Of course it is folly to iterate forever, so I have my code give up after 10 tires. Here is a snip:
int count = 0;
while (true)
{
try
{
MySPPersistedObject obj = FindMyObject(id);
obj.SomeOperation();
obj.Update();
break;
}
catch (SPUpdatedConcurrencyException)
{
count++;
if (count > 10)
{
throw;
}
}
}
No comments:
Post a Comment