Configuring Threadpool Max Threads via app.config?

前端 未结 2 766
暖寄归人
暖寄归人 2021-01-15 10:19

Can I configure the max threads via the config file?

2条回答
  •  孤独总比滥情好
    2021-01-15 11:05

    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.

提交回复
热议问题