/// <summary> /// Initializes a new instance of the <see cref="JobHost"/> class using the configuration provided. /// </summary> /// <param name="configuration">The job host configuration.</param> public JobHost(JobHostConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _config = configuration; _shutdownTokenSource = new CancellationTokenSource(); _shutdownWatcher = WebJobsShutdownWatcher.Create(_shutdownTokenSource); _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_shutdownTokenSource.Token); }
/// <summary> /// Initializes a new instance of the <see cref="JobHost"/> class using the configuration provided. /// </summary> /// <param name="configuration">The job host configuration.</param> public JobHost(IOptions <JobHostOptions> options, IJobHostContextFactory jobHostContextFactory) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options.Value; _jobHostContextFactory = jobHostContextFactory; _shutdownTokenSource = new CancellationTokenSource(); _shutdownWatcher = WebJobsShutdownWatcher.Create(_shutdownTokenSource); _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_shutdownTokenSource.Token); }
/// <summary> /// Initializes a new instance of the <see cref="JobHost"/> class using the service provider provided. /// </summary> /// <param name="serviceProvider">The service provider.</param> internal JobHost(IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } _contextFactory = serviceProvider.GetJobHostContextFactory(); if (_contextFactory == null) { throw new InvalidOperationException("The IJobHostContextFactory service must not be null."); } _shutdownTokenSource = new CancellationTokenSource(); _shutdownWatcher = WebJobsShutdownWatcher.Create(_shutdownTokenSource); _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_shutdownTokenSource.Token); }