An apartment is a set of threading rules sharedby a group of objects。The three types of apartments aresingle-threaded apartments (STAs), neutral apartments (NAs), and multithreadedapartments (MTAs).
每一个STA中只能由一个线程,MTA中可以有多个线程。一个process可以有多个STA, 但只能有一个MTA, 一个NA。
组件中的对象支持的线程模型与Apartment之间的关系:
ThreadingModel Values | Description |
---|---|
Not present | Single-threaded legacy component that runs only in the main STA |
Apartment | STA |
Neutral | NA |
Free | MTA |
Both | Supports the STA, NA, and MTA models |
现在我们知道的信息是组件中对象支持的threading model,这个可以通过注册表中的InprocServer32键值获取。