What will happen when the STA object host thread exist?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I just thought one scenario during development.
Say I have one COM object whose threading model was defined as Apartment. In one STA thread this object instance was created and later its interface was passing to another thread (could be another STA thread or MTA thread) through marshaling. Later this
STA thread existed due to some certain error. But this COM object instance is still alive because as we know its lifetime is managed by reference count. Then one call to this COM object was made from another thread. I dont know what will happen in this scenario.
As documented, the call to any Apartment Object was dispatched through message loop in its host thread. In the case mentioned above, since the host thread already existed, how could the message be dispatched and how could this Apartment Object get called?

Thanks.


View the full article
 
Back
Top