How to lock SharePoint list / items in processes / machines?

In general, is there a good way in SharePoint to control race conditions because of two processes or even two machines in a farm running on the same list or list item at the same time? That is, is there any mechanism built-in or that can be generated using the object model to perform a cross-process or block individual list items across multiple machines?

I want to write a timer job that does a bunch of manipulations in a list. This list is written using the SharePoint user interface and then read by the user interface. I want to be able to make sure that the user interface does not write or read from the list when it is in an inconsistent state due to the fact that the timer job is in the middle of the manipulation. Is there any way to do this?

In addition, I want to allow multiple instances of the timer job to run simultaneously. This, again, will require locking to make sure that two jobs are not trying to work with the same list / item at the same time.

TIA for any help!

+4
source share
2 answers

Look how

  • standard document library implements verification / registration
  • this effectively blocks the SP element matching the document

Then you can

  • create your own list
  • using the same exit / registration approach

Hope this helps

+1
source

I believe (but have no way to verify) that an optimistic concurrency control at the list item level is built-in.

If you really need an application to manage locking (for example, at the list level), maybe its smell of code that you click on SharePoint is too strong, and you should use RDBMS (for example, SQL Server) with full ACID Properties ?

0
source

Source: https://habr.com/ru/post/1309470/


All Articles