如何获得第二个 System.Thread.ThreadPool?

How to get a second System.Thread.ThreadPool?(如何获得第二个 System.Thread.ThreadPool?)
本文介绍了如何获得第二个 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 实现的多个实例,例如 SmartThreadPool.从技术上讲,这将允许单独的线程池".

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".

但是,我怀疑您因为 死锁 而挂起,而不是因为线程池用法.我会调查你在哪里遇到问题.如果您安装了 VS 2010 测试版的副本,则 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

LINQ to SQL query using quot;NOT INquot;(使用“NOT IN的 LINQ to SQL 查询)
How to do a full outer join in Linq?(如何在 Linq 中进行完整的外部联接?)
LINQ to SQL Web Application Best Practices(LINQ to SQL Web 应用程序最佳实践)
How do I group data in an ASP.NET MVC View?(如何在 ASP.NET MVC 视图中对数据进行分组?)
how to update the multiple rows at a time using linq to sql?(如何使用 linq to sql 一次更新多行?)
how to recognize similar words with difference in spelling(如何识别拼写不同的相似词)