How to get a second System.Thread.ThreadPool?

前端 未结 6 1820
自闭症患者
自闭症患者 2021-01-18 23:16

If I use the ThreadPool in a nested way, my application hangs:

 ThreadPool.QueueUserWorkItem((state) =>
      ThreadPool.QueueUserWorkItem(Action));
         


        
6条回答
  •  野的像风
    2021-01-18 23:58

    While the Windows API allows for multiple Thread Pools in a process, .NET does not directly expose this. In the .NET Framework..

    There is Exactly One .NET ThreadPool per .NET AppDomain, and absolutely no way to change this.

    So with different application domains.. it is possible to have different .NET ThreadPools within the same process.

    (NOTE: The heuristics for the Hill Climb algorithm used in .NET is also determined on a per-.NET ThreadPool basis. This, along without being able to specify a maximum number of workers per type, is a downside of a 'global per appdomain' ThreadPool with varied workloads.)

提交回复
热议问题