How Can I determine the number of items in ThreadPool Queue

前端 未结 2 1629
深忆病人
深忆病人 2021-01-12 11:13

I am using the ThreadPool to queue 1000\'s of workitems

While(reading in data for processing)
{
    args = some data that has been read;
    ThreadPool.Queue         


        
2条回答
  •  有刺的猬
    2021-01-12 11:30

    I don't think there is a built-in way, but you can introduce a [static?] counter that would increase/decrease; for that you would have to create your own method that would wrap ThreadPool.QueueUserWorkItem() and take care of the counter.

    By the way, just in case you are running .NET 4.0, you should use TaskFactory.StartNew instead of ThreadPool.QueueUserWorkItem() - it's said to have better memory/thread management.

提交回复
热议问题