如何告诉线程池在STA线程上运行委托? [英] How to tell thread-pool to run a delegate on a `STA` thread?

查看:134
本文介绍了如何告诉线程池在STA线程上运行委托?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need a thread-pool for working with COM objects inside an ASP.NET project.

QueueUserWorkItemSTA(WaitCallback)

推荐答案

摘自智能线程池:

还请注意,.NET ThreadPool 不支持通过调用COM 单线程公寓(STA),自 ThreadPool线程是MTA通过 设计.

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.

因此,我想如果您尝试一下智能线程池,它就可以满足您的要求.

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.

这篇关于如何告诉线程池在STA线程上运行委托?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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