Definition of Apartment
• COM objects in the process are divided into groups called apartments.
• A COM object lives in exactly one apartment, in the sense that its methods com legally be directly called only by a thread that belongs to that apartment. Any other thread that wants to call the object must go through a proxy.
COM Threading Architecture is as below.
[PROCESS]
[Object]
Apartment
Difference between Single Threaded and Multi Threaded apartment
Single Threaded
• Single threaded apartment consist of exactly one thread.
• All COM objects that live in a single threaded apartment. COM receives method calls only from the one thread that belongs to that apartment.
• All method calls to a com objects are synchronized with the windows message queue.
• A process with a single thread is simply a special case of this mode.
Multi Threaded
• Multi threaded apartment consist of one or more thread.
• All COM objects can receive methods calls directly from any of the threads that belong to the multi-threaded apartments.
• All method calls to COM objects are synchronized by the objects themselves.
• Threads in MTA use model called free threading.
0 comments:
Post a Comment