This is a helper class for retrieving + caching the number of threads available:
```cs
public static class ThreadStatistics
{
public static int ThreadCount;
public static int BackgroundThreadCount;
static ThreadStatistics()
{
ThreadPool.GetMinThreads(out ThreadCount, out _);
// Minus 1 to avoid running Tasks on the main thread
// Must be at least 1 to ensure Tasks get run
BackgroundThreadCount = Math.Max(1, ThreadCount - 1);
}
}
```