.Net How to create a custom ThreadPool shared across all the AppDomain of a process?

前端 未结 2 535
天命终不由人
天命终不由人 2021-02-10 15:38

I made a custom ThreadPool optimized for my specific needs. However, when there are multiple AppDomains in the process, the CLR ThreadPool is able to be shared across all the Ap

2条回答
  •  眼角桃花
    2021-02-10 16:12

    Create a new threadpool instance in each appdomain, but then use a semaphore to control the total number of threads running across all instances. This means you can still get the same total concurrent jobs processed, but don't have the grief of marshalling.

    The MSDN docs have an example.

提交回复
热议问题