public virtual void Run(object state)
        {
            var jobExecutorContext = new JobExecutorContext();

            var currentProcessorJobQueue     = jobExecutorContext.CurrentProcessorJobQueue;
            ICommandExecutor commandExecutor = ((ProcessEngineConfigurationImpl)_processEngine.ProcessEngineConfiguration).CommandExecutorTxRequired;

            _jobIds.ForEach(d =>
            {
                currentProcessorJobQueue.Enqueue(d);
            });

            Context.JobExecutorContext = jobExecutorContext;
            try
            {
                while (!currentProcessorJobQueue.IsEmpty())
                {
                    string nextJobId = currentProcessorJobQueue.Dequeue();
                    if (_jobExecutor.IsActive)
                    {
                        try
                        {
                            ExecuteJob(nextJobId, commandExecutor);
                        }
                        catch (System.Exception t)
                        {
                            Log.ExceptionWhileExecutingJob(nextJobId, t);
                        }
                    }
                    else
                    {
                        try
                        {
                            UnlockJob(nextJobId, commandExecutor);
                        }
                        catch (System.Exception t)
                        {
                            Log.ExceptionWhileUnlockingJob(nextJobId, t);
                        }
                    }
                    currentProcessorJobQueue.TrimExcess();
                }

                // if there were only exclusive jobs then the job executor
                // does a backoff. In order to avoid too much waiting time
                // we need to tell him to check once more if there were any jobs added.
                _jobExecutor.JobWasAdded();
            }
            finally
            {
                Context.RemoveJobExecutorContext();
            }
        }
 public ExclusiveJobAddedNotification(string jobId, JobExecutorContext jobExecutorContext)
 {
     this.JobId = jobId;
     this.JobExecutorContext = jobExecutorContext;
 }