COM Apartments
Whether you register a managed object using the Assembly Registration Tool (regasm) or you use one of the activation functions that do not require registration, like ClrCreateManagedInstance, a managed object behaves like a COM object with the Both threading model when called from an unmanaged client. In other words, the object will run on the same thread as its caller whether the calling thread resides within an STA or an MTA. The implication of this is that, if you are going to call a managed object from a multithreaded unmanaged client, you need to make sure that the managed object is thread safe. With COM, if you did not want to write thread synchronization code, you could simply specify that your object use an STA. With the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access