Reputation: 489
Can I configure the max threads via the config file?
Upvotes: 2
Views: 8060
Reputation: 594
Not quite "the" config file, but these days you can set the threadpool worker maximum using runtimeconfig.json
:
{
"runtimeOptions": {
"configProperties": {
"System.Threading.ThreadPool.MaxThreads": 20
}
}
}
I have not tried this myself (yet).
https://learn.microsoft.com/de-de/dotnet/core/runtime-config/threading#maximum-threads
Upvotes: 0
Reputation: 241789
Not directly. But you could read the desired value of maximum number of threads in the thread pool from a config file and pass the values to ThreadPool.SetMaxThreads
.
But if you need to change the number of threads in the thread pool you should seriously consider rearchitecting your application.
Note, in particular:
Setting the thread pool size too large can cause performance problems. If too many threads are executing at the same time, the task switching overhead becomes a significant factor.
Upvotes: 0
Reputation: 564901
No - However, this can be set based on configuration values you read, by calling ThreadPool.SetMaxThreads.
Upvotes: 6