views:

178

answers:

1

In general, is there a decent way in SharePoint to control race conditions due to two processes or even two machines in the farm operating on the same list or list item at the same time? That is, is there any mechanism either built in or that can be fabricated via the Object Model for doing cross-process or cross-machine locking of individual list items?

I want to write a timer job that performs a bunch of manipulations on a list. This list is written to by the SharePoint UI and then read by the UI. I want to be able to make sure that the UI doesn't either write to or read from the list when it is in an inconsistent state due to the timer job being in the middle of a manipulation. Is there any way to do this?

Also, I want to allow for multiple instances of the timer job to run simultaneously. This, again, will require a lock to be sure that the two jobs don't attempt to operate on the same list/item at the same time.

TIA for any help!

A: 

I believe (but don't have chance to test) that optimistic concurrency control at the list item level is built in.

If you're application truly does need more control over locking (such as at list level) then perhaps its a code smell that you're pushing SharePoint lists too hard and you should be using a RDBMS (e.g. SQL Server) with full ACID properties?

Ryan