I'm exploring NCron to be used as a scheduler host for running several sftp jobs. Is there any way to restrict the job from running if already an existing instance is running? I have gone through the wiki but can't find any details on this.
How to run only a single instance of NCron job at any time
133 views Asked by lyf At
1
Ensuring that a job is not executed multiple times in parallel can be done by wrapping the body of the
Execute()method in alockblock. However, due to the nature of thelockstatement, this will cause executions of the job in question to be queued, which may or may not be what you want.If you would rather that the execution of the job is skipped when the job is already running, this can be solved with a
static booland and a littlelock,ifandtry. Here is a first and untested attempt at building a base class for such jobs: https://gist.github.com/schourode/7639291I would love to receive feedback on this experiment. If successful, this could very well make it into the NCron core assembly.