如何获得第二个System.Thread.ThreadPool? [英] How to get a second System.Thread.ThreadPool?

查看:75
本文介绍了如何获得第二个System.Thread.ThreadPool?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我以嵌套方式使用ThreadPool,则我的应用程序将挂起:

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

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

如何获得第二个独立的ThreadPool来实现嵌套?

How to get a second and independent ThreadPool to achieve nesting?

推荐答案

只有一个单独的ThreadPool-您不能(或应该)在一个应用程序中创建多个实例.

There is only one single ThreadPool - it's not something you can (or should) make more than one instance of in an application.

我不建议您这样做,但是如果您确实想这样做,则可以使用自己的ThreadPool实现的多个实例,例如

I don't recommend doing this, but if you really wanted to, you could use multiple instances of your own ThreadPool implementation, such as SmartThreadPool. This would, technically, allow separate "thread pools".

但是,我怀疑您是由于死锁而死的,而不是因为ThreadPool用法.我会调查您的问题所在.如果您已安装VS 2010 Beta的副本,则VS2010并发可视化工具非常适合此操作.

However, I suspect you're hanging due to a deadlock, not due to the ThreadPool usage. I would investigate where you're getting the hangs. The VS2010 concurrency visualizer is very nice for this, if you have a copy of the VS 2010 beta installed.

这篇关于如何获得第二个System.Thread.ThreadPool?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆