/// <inheritdoc />
        public ThreadPoolMonitoringService(
            ThreadPoolOptions options,
            ILogger <ThreadPoolMonitoringService> logger)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            options.AssertValid();

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
示例#2
0
        public ThreadPoolInitializer(
            ThreadPoolOptions options,
            ILogger <ThreadPoolInitializer> logger)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            options.AssertValid();

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
示例#3
0
        /// <summary>
        /// Adds to services thread pool monitoring and tuning classes.
        /// </summary>
        public static IServiceCollection AddThreadPoolTuning(
            this IServiceCollection services,
            ThreadPoolOptions threadPoolOptions)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (threadPoolOptions == null)
            {
                throw new ArgumentNullException(nameof(threadPoolOptions));
            }

            threadPoolOptions.AssertValid();

            services.TryAddSingleton(threadPoolOptions);
            services.AddAppInitializer <ThreadPoolInitializer>();
            services.AddSingleton <IHostedService, ThreadPoolMonitoringService>();

            return(services);
        }