如果两个没有线程模型的 COM 类在一个进程内 COM 服务器中实现,会发生什么情况?
考虑一种情况。我有一个进程内 COM 服务器,其中包含两个 COM 类。这两个类在注册表中都被标记为“无线程模型”——“ThreadingModel”值不存在。两个类都读/写同一组全局变量,无需任何同步。
据我所知,“无线程模型”将强制 COM 禁止不同线程并发访问同一类的相同或不同实例。
COM 会阻止对上述两个不同类的实例的并发访问吗?在这种情况下,从两个不同的 COM 类访问全局变量时是否需要同步?
Consider a situation. I have an in-proc COM server that contains two COM classes. Both classes are marked as "no threading model" in the registry - the "ThreadingModel" value is just absent. Both classes read/write the same set of global variable without any synchronization.
As far as I know "no threading model" will enforce COM to disallow concurrent access to the same or different instances of the same class by different threads.
Will COM prevent concurrent access to instances of the two abovementioned different classes? Do I need synchronization when accessing the global variables from two different COM classes in this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 ThreadingModel 不存在时,它默认为 Main STA 或 Legacy STA。所有旧版组件始终在此旧版 STA 中创建。有关更多详细信息,我建议阅读
http://www.codeproject.com/kb/com/CCOMThread.aspx
When the ThreadingModel is absent then the it defaults to Main STA or Legacy STA. All the legacy components are always created in this Legacy STA. For more details, I would recommend reading
http://www.codeproject.com/kb/com/CCOMThread.aspx