COM Apartments

Team-Fly    

 
.NET and COM Interoperability Handbook, The
By Alan Gordon
Table of Contents
Chapter Eight.  Advanced COM to .NET Interop

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 .NET Framework, if multithreaded clients will use your managed class, you must write thread synchronization code using the System.Threading.Monitor or System.Threading.Mutex classes. You can also use the lock statement in C#, which simplifies the use of System.Threading.Monitor .


Team-Fly    
Top
 


. Net and COM Interoperability Handbook
The .NET and COM Interoperability Handbook (Integrated .Net)
ISBN: 013046130X
EAN: 2147483647
Year: 2002
Pages: 119
Authors: Alan Gordon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net