public IServiceProvider CreateServiceProvider(IServiceCollection containerBuilder)
        {
            if (_provider == null)
            {
                _provider = new JobHostServiceProvider(containerBuilder, _rootProvider, _rootScopeFactory);
            }

            return(_provider);
        }
        public IServiceProvider CreateServiceProvider(IServiceCollection containerBuilder)
        {
            try
            {
                _validator.Validate(containerBuilder);
            }
            catch (InvalidHostServicesException ex)
            {
                // Log this to the WebHost's logger so we can track
                ILogger logger = _rootProvider.GetService <ILogger <DependencyValidator> >();
                logger.LogError(ex, "Invalid host services detected.");
            }

            if (_provider == null)
            {
                _provider = new JobHostServiceProvider(containerBuilder, _rootProvider, _rootScopeFactory);
            }

            return(_provider);
        }