public void StartBatchJob(Action <int> handler, BatchJobOptions options) { lock (batchJobLock) { if (batchJob == null || !batchJob.IsRunning) { batchJob = new BatchJob(options, logger); batchJob.Start(handler); } else { throw new InvalidOperationException("Batch job already started."); } } }
public void StopBatchJob() { lock (batchJobLock) { if (batchJob != null) { try { batchJob.Stop(); } finally { batchJob = null; } } else { throw new InvalidOperationException("Batch job does not exist."); } } }