Could you explain STA and MTA?

前端 未结 7 2238
梦如初夏
梦如初夏 2020-11-22 04:12

Can you explain STA and MTA in your own words?

Also, what are apartment threads and do they pertain only to COM? If so, why?

7条回答
  •  借酒劲吻你
    2020-11-22 05:06

    Code that calls COM object dlls (for example, to read proprietary data files), may work fine in a user interface but hang mysteriously from a service. The reason is that as of .Net 2.0 user interfaces assume STA (thread-safe) while services assume MTA ((before that, services assumed STA). Having to create an STA thread for every COM call in a service can add significant overhead.

提交回复
热议问题