1

What is the best practice to ensure that a SharePoint timer job runs only once?

Using SPJobLockType.Job ensures that it is only started on one machine. But how do I prevent a new instance from being started while a previous instance is still running? How can I determine if a previous instance is still running to block a manual start of the timer job?

I see two possible solutions:

1) Test if a previous instance is still running though some API functionality. I am not aware of such API functionality.

2) Use a semaphore. But how can I reliably reset the semaphore in case of a power failure...?

Marek Grzenkowicz
  • 17,024
  • 9
  • 81
  • 111
Peter P.
  • 191
  • 1
  • 6

0 Answers0