What happens if two COM classes each without a threading model are implemented in one in-proc COM server?
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 glob开发者_如何学Cal 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?
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
精彩评论