Re: STA component call MTA component
"George" <George@discussions.microsoft.com> wrote in message
news:B56B6B8C-8A8F-4C87-AFEE-491F3FD4D413@microsoft.com
COM maintains a pool of threads for MTA apartment. A thread from this
pool is selected to run the method (a new thread may be created if
necessary).
Confused. In my current knowledge, a process could only have one MTA.
Yes.
When creating MTA, we explicitly create threads and use
CoInitializeEx to assign MTA property.
Yes, you can create threads and have them join MTA (of which there is
only one in the process). So can COM runtime.
Do you mean besides the explicit created threads (e.g. using the ones
created by _beginthreadex or something peer function API), COM
Runtime will maintain an additional thread pool?
Yes.
If yes, what are the purpose for the threads in the thread pool
Accepting and running incoming COM calls, of course. As you yourself
noted, your own threads can't do that.
STA thread will run a message pump while waiting for the call to
return, which may cause reentrancy. Apart from the reentrancy issue,
the call is synchronous.
You mean while STA is waiting for reply from MTA, it will continue to
retrieve message from its own (STA's) message queue to execute
incoming method calls?
Yes.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925