/// <summary>
 /// Initializes a new instance of the JobRunner class.
 /// </summary>
 /// <param name="store">The <see cref="IJobStore"/> to use when accessing job data.</param>
 /// <param name="runningJobsPersistencePath">The path to use when saving running jobs state to disk.</param>
 /// <param name="deleteRecordsOnSuccess">A value indicating whether to delete records after successful job runs.</param>
 /// <param name="heartbeat">The heartbeat, in milliseconds, to poll for jobs with.</param>
 /// <param name="maximumConcurrency">The maximum number of simultaneous jobs to run.</param>
 /// <param name="retryTimeout">The timeout, in milliseconds, to use for failed job retries.</param>
 /// <param name="enabled">A value indicating whether dequeueing new jobs is enabled.</param>
 /// <param name="schedules">The collection of scheduled jobs to run.</param>
 public JobRunner(IJobStore store, string runningJobsPersistencePath, bool deleteRecordsOnSuccess, int heartbeat, int maximumConcurrency, int retryTimeout, bool enabled, IEnumerable<JobScheduleElement> schedules)
 {
     this.store = store ?? JobStore.Current;
     this.runs = new RunningJobs(runningJobsPersistencePath);
     this.deleteRecordsOnSuccess = deleteRecordsOnSuccess;
     this.heartbeat = heartbeat < 1 ? 10000 : heartbeat;
     this.maximumConcurrency = maximumConcurrency < 1 ? 25 : maximumConcurrency;
     this.retryTimeout = retryTimeout < 1 ? 60000 : retryTimeout;
     this.isEnabled = enabled;
     this.SetSchedules(schedules);
 }
        /// <summary>
        /// Disposes of resources used by this instance.
        /// </summary>
        /// <param name="disposing">A value indicating whether to dispose of managed resources.</param>
        private void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (this.runs != null)
                    {
                        this.runs.AbortAll();
                        this.runs.Flush();
                        this.runs = null;
                    }

                    if (this.god != null && this.god.IsAlive)
                    {
                        this.god.Abort();
                        this.god = null;
                    }
                }

                this.disposed = true;
            }
        }