This threading model is recommended for components that will be called by Active Server Pages.
Each apartment-model object may only be entered by one thread, the thread that called CoCreateInstance. However, an object server can support multiple objects each being entered simultaneously by different threads. Common data held by the object server must be protected against thread collisions.
The Web server creates an apartment-model object in the same thread that called CoCreateInstance. Calls to the object from the apartment thread are not marshaled. Requests that are in the same session as an apartment model object are handled by the thread that created the apartment model object.
One disadvantage of apartment-threaded objects is that they cannot be stored in the Application object. The only way to create an apartment-threaded object with application scope is to declare it with an <OBJECT> tag. However, when this object is used, the Web server will lock the application down to a single thread, the one that created the object. This will reduce server performance significantly, and should only be considered for intranet applications.
In addition, if an apartment-threaded object is created with session scope or is stored in the Session object, the Web server will lock the session down to the single thread that created the object.
© Microsoft Corporation. All rights reserved.