A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.microsoft.com/dotnet/core/run-time-config/threading below:

Threading config settings - .NET

This article details the settings you can use to configure threading in .NET.

Note

.NET 6 standardizes on the prefix DOTNET_ instead of COMPlus_ for environment variables that configure .NET run-time behavior. However, the COMPlus_ prefix will continue to work. If you're using a previous version of the .NET runtime, you should still use the COMPlus_ prefix for environment variables.

Use all CPU groups on Windows Setting name Values runtimeconfig.json N/A N/A Environment variable COMPlus_Thread_UseAllCpuGroups or DOTNET_Thread_UseAllCpuGroups 0 - disabled
1 - enabled Assign threads to CPU groups on Windows Setting name Values runtimeconfig.json N/A N/A Environment variable COMPlus_Thread_AssignCpuGroups or DOTNET_Thread_AssignCpuGroups 0 - disabled
1 - enabled Minimum threads Setting name Values runtimeconfig.json System.Threading.ThreadPool.MinThreads An integer that represents the minimum number of threads MSBuild property ThreadPoolMinThreads An integer that represents the minimum number of threads Environment variable N/A N/A Examples

runtimeconfig.json file:

{
   "runtimeOptions": {
      "configProperties": {
         "System.Threading.ThreadPool.MinThreads": 4
      }
   }
}

runtimeconfig.template.json file:

{
   "configProperties": {
      "System.Threading.ThreadPool.MinThreads": 4
   }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <ThreadPoolMinThreads>4</ThreadPoolMinThreads>
  </PropertyGroup>

</Project>
Maximum threads Setting name Values runtimeconfig.json System.Threading.ThreadPool.MaxThreads An integer that represents the maximum number of threads MSBuild property ThreadPoolMaxThreads An integer that represents the maximum number of threads Environment variable N/A N/A Examples

runtimeconfig.json file:

{
   "runtimeOptions": {
      "configProperties": {
         "System.Threading.ThreadPool.MaxThreads": 20
      }
   }
}

runtimeconfig.template.json file:

{
   "configProperties": {
      "System.Threading.ThreadPool.MaxThreads": 20
   }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <ThreadPoolMaxThreads>20</ThreadPoolMaxThreads>
  </PropertyGroup>

</Project>
Windows thread pool Setting name Values Version introduced runtimeconfig.json System.Threading.ThreadPool.UseWindowsThreadPool true - enabled
false - disabled .NET 8 MSBuild property UseWindowsThreadPool true - enabled
false - disabled .NET 8 Environment variable DOTNET_ThreadPool_UseWindowsThreadPool 1 - enabled
0 - disabled .NET 8 Examples

runtimeconfig.json file:

{
   "runtimeOptions": {
      "configProperties": {
         "System.Threading.ThreadPool.UseWindowsThreadPool": true
      }
   }
}

runtimeconfig.template.json file:

{
   "configProperties": {
      "System.Threading.ThreadPool.UseWindowsThreadPool": true
   }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <UseWindowsThreadPool>true</UseWindowsThreadPool>
  </PropertyGroup>

</Project>
Thread injection in response to blocking work items

In some cases, the thread pool detects work items that block its threads. To compensate, it injects more threads. In .NET 6+, you can use the following runtime configuration settings to configure thread injection in response to blocking work items. Currently, these settings take effect only for work items that wait for another task to complete, such as in typical sync-over-async cases.

runtimeconfig.json setting name Description Version introduced System.Threading.ThreadPool.Blocking.ThreadsToAddWithoutDelay_ProcCountFactor After the thread count based on MinThreads is reached, this value (after it is multiplied by the processor count) specifies how many additional threads may be created without a delay. .NET 6 System.Threading.ThreadPool.Blocking.ThreadsPerDelayStep_ProcCountFactor After the thread count based on ThreadsToAddWithoutDelay is reached, this value (after it is multiplied by the processor count) specifies after how many threads an additional DelayStepMs would be added to the delay before each new thread is created. .NET 6 System.Threading.ThreadPool.Blocking.DelayStepMs After the thread count based on ThreadsToAddWithoutDelay is reached, this value specifies how much additional delay to add per ThreadsPerDelayStep threads, which would be applied before each new thread is created. .NET 6 System.Threading.ThreadPool.Blocking.MaxDelayMs After the thread count based on ThreadsToAddWithoutDelay is reached, this value specifies the max delay to use before each new thread is created. .NET 6 System.Threading.ThreadPool.Blocking.IgnoreMemoryUsage By default, the rate of thread injection in response to blocking is limited by heuristics that determine whether there is sufficient physical memory available. In some situations, it may be preferable to inject threads more quickly even in low-memory situations. You can disable the memory usage heuristics by turning off this switch. .NET 7 How the configuration settings take effect Examples

runtimeconfig.json file:

{
   "runtimeOptions": {
      "configProperties": {
         "System.Threading.ThreadPool.Blocking.ThreadsToAddWithoutDelay_ProcCountFactor": 5
      }
   }
}

runtimeconfig.template.json file:

{
   "configProperties": {
      "System.Threading.ThreadPool.Blocking.ThreadsToAddWithoutDelay_ProcCountFactor": 5
   }
}
AutoreleasePool for managed threads

This option configures whether each managed thread receives an implicit NSAutoreleasePool when running on a supported macOS platform.

Setting name Values Version introduced runtimeconfig.json System.Threading.Thread.EnableAutoreleasePool true or false .NET 6 MSBuild property AutoreleasePoolSupport true or false .NET 6 Environment variable N/A N/A N/A Examples

runtimeconfig.json file:

{
   "runtimeOptions": {
      "configProperties": {
         "System.Threading.Thread.EnableAutoreleasePool": true
      }
   }
}

runtimeconfig.template.json file:

{
   "configProperties": {
      "System.Threading.Thread.EnableAutoreleasePool": true
   }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <AutoreleasePoolSupport>true</AutoreleasePoolSupport>
  </PropertyGroup>

</Project>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4