private void DoExecute(JobExecutionRequest jobExecutionRequest)
        {
            _topLevelJob.Value = jobExecutionRequest;

            Log($"Executing {jobExecutionRequest.JobSummary()}");
            Interlocked.Increment(ref _outstandingCount);
            var task = jobExecutionRequest.ExecuteJob();

            WithLock(() => _outstandingTasks.Add(task),
                     () => Log($"Failed to add job {jobExecutionRequest.JobSummary()} to running list"));
            try
            {
                task.Wait();
            }
            finally
            {
                Log($"Finished executing {jobExecutionRequest.JobSummary()}");
                WithLock(lockObject =>
                {
                    _outstandingTasks.Remove(task);
                    Interlocked.Decrement(ref _outstandingCount);
                    Monitor.Pulse(lockObject);
                },
                         () => Log($"Failed to remove job {jobExecutionRequest.JobSummary()} from running list"));
                if (ReferenceEquals(_topLevelJob.Value, jobExecutionRequest))
                {
                    _topLevelJob.Value = null;
                }
            }
        }
 private void ExecuteRequest(JobExecutionRequest jobExecutionRequest)
 {
     Log($"Executing {jobExecutionRequest.JobSummary()}");
     try
     {
         var executionTask = jobExecutionRequest.ExecuteJob();
         executionTask.Wait();
     }
     catch (Exception e)
     {
         Log($"Job execution {jobExecutionRequest.JobSummary()} failed - {e.Message}");
     }
 }
 private void ExecuteRequest(JobExecutionRequest jobExecutionRequest)
 {
     if (_topLevelJob.Value != null)
     {
         Log($"Executing {jobExecutionRequest.JobSummary()} directly as called within context of existing job");
         jobExecutionRequest.ExecuteJob().Wait();
     }
     else
     {
         Log($"Enqueing {jobExecutionRequest.JobSummary()}");
         _jobTaskFactory.StartNew(() => DoExecute(jobExecutionRequest));
     }
 }