Microsoft KB Archive/313706

= INFO: COM+ Component Without Synchronization Component Activates in Host STA =

Article ID: 313706

Article Last Modified on 6/19/2002

-

APPLIES TO


 * Microsoft COM+ 1.0

-



This article was previously published under Q313706



SUMMARY
COM+ activates a configured Apartment component in the Host single-threaded apartment (Host STA) unless the Concurrency setting is set to Required or Requires New.



MORE INFORMATION
COM rules state that if a component marked as Apartment is instantiated from a non-STA thread, the component activates in the Host STA for that process. The result is marshaling and very bad serialization, especially if many other components are instantiated in the Host STA.

If COM has not already created the Main STA (when a single threaded legacy component is instantiated), it creates the Host STA (which now also becomes the Main STA). Regardless of whether you name it the Host STA or the Main STA, the purpose of the Host STA is to host components that are marked Apartment and instantiated from a non-STA thread. Because an STA thread is needed for an Apartment instance, and one does not exist in the non-STA activation case, one must be created. This happens from a multi-threaded apartment (MTA) activator thread, from an out-of-process activator thread, and from the neutral apartment (NA) activator for that process.

COM+ activities provide hints to the Service Control Manager (SCM) with respect to activation proximity. For components that are used in the same logical chain of execution, COM+ groups them into the same activity. This conserves the limited COM+ STA pool threads and minimizes cross-apartment calls to maximize performance. This optimization further complicates the activation process and changes default COM activation behavior.

Activation proceeds as follows, depending on which COM+ Concurrency setting is used to mark a component:
 * If a component is marked as Required Concurrency, COM+ binds that instance to the same pooled STA thread that is already bound to the synchronization boundary that it is a part of.
 * If a component is marked as Requires New Concurrency, COM+ binds that instance to a new STA thread because it is starting its own synchronization boundary. In this case, it does not matter whether the call is made in-process or not.
 * If a component is marked with a Concurrency setting other than Disabled, Not Supported, or Supported, COM+ views it as not explicitly being part of another synchronization boundary and does not waste an STA from its thread pool on it. You may expect Supported to not adhere to this rule, but that is how COM+ handles that setting. Therefore, it will be activated in the Host STA, which is not a good choice.

NOTE: COM+ binds up to 5 activities (also known as synchronization boundaries) to one pooled STA thread.

Additional query words: missing synchro syncroniz

Keywords: kbinfo KB313706

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.