Skip to content
Open
39 changes: 39 additions & 0 deletions docs/core/runtime-config/threading.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Threading config settings
description: Learn about the settings that configure threading for .NET apps.
ms.date: 11/04/2021
ai-usage: ai-assisted
---
# Runtime configuration options for threading
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot keep all the old content, just add the new at the bottom

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit db3f8b3. Restored all original content and added the new DOTNET_Thread_DefaultStackSize section at the bottom.


Expand Down Expand Up @@ -265,3 +266,41 @@ Project file:

</Project>
```

## Default stack size for new threads

- Configures the default stack size for threads created by <xref:System.Threading.Thread> and other APIs that don't specify an explicit stack size. The value is specified as a hexadecimal number representing bytes. This setting doesn't affect the main application thread.
- If not specified, the default stack size is determined by the operating system.

| | Setting name | Values | Version introduced |
| - | - | - | - |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This is only available on all platforms starting in .NET 10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 4892484. Updated both the runtimeconfig.json property and environment variable to show ".NET 10" as the version introduced.

| **runtimeconfig.json** | `System.Threading.DefaultStackSize` | A hexadecimal integer value representing stack size in bytes. | .NET 10 |
| **MSBuild property** | N/A | N/A | N/A |
| **Environment variable** | `DOTNET_Thread_DefaultStackSize` | A hexadecimal integer value representing stack size in bytes. | .NET 10 |

### Examples

*runtimeconfig.json* file:

```json
{
"runtimeOptions": {
"configProperties": {
"System.Threading.DefaultStackSize": "0x100000"
}
}
}
```

*runtimeconfig.template.json* file:

```json
{
"configProperties": {
"System.Threading.DefaultStackSize": "0x100000"
}
}
```

> [!NOTE]
> This setting doesn't affect threads that explicitly specify a stack size at creation.