简体   繁体   English

如何告诉线程池在STA线程上运行委托?

[英]How to tell thread-pool to run a delegate on a `STA` thread?

我需要一个线程池来处理ASP.NET项目中的COM对象。

QueueUserWorkItemSTA(WaitCallback)

From the CodeProject Article of Smart Thread Pool : 摘自Smart Thread Pool的CodeProject文章:

Also note that the .NET ThreadPool doesn't support calls to COM with single threaded apartment (STA), since the ThreadPool threads are MTA by design. 还要注意,.NET ThreadPool不支持使用单线程单元(STA)调用COM,因为ThreadPool线程在设计上是MTA。

So I assume if you give the Smart Thread Pool a try, it could fit your requirements. 因此,我假设如果您尝试使用智能线程池,它就可以满足您的要求。

Personally, I use this class successfully since severals years. 就个人而言,几年以来,我成功地使用了这门课。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM