using System;
using System.Threading;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;

namespace Requests
{
	public class Program
	{
		public static int Requests;

		public static void Main(string[] args)
		{
			new Thread(_ =>
			{
				while (true)
				{
					ThreadPool.GetAvailableThreads(out var available, out var _);
					ThreadPool.GetMaxThreads(out var maxThreads, out var _);
					ThreadPool.GetMinThreads(out var minThreads, out var _);

					Console.WriteLine($"Requests: {Volatile.Read(ref Requests)}, Available: {available}, Active: {maxThreads - available}, Min: {minThreads}, Max: {maxThreads}");

					Thread.Sleep(1000);
				}
			})
			{
				IsBackground = true,
			}.Start();

			WebHost.CreateDefaultBuilder(args)
				.UseStartup<Startup>()
				.ConfigureLogging(logging =>
				{
					logging.SetMinimumLevel(LogLevel.Warning);
				}).Build().Run();
		}
	}
}
