Single-Threaded

This threading model is not recommended for components that will be called by Active Server Pages.

Single-threaded objects run in exactly one thread, the one that called the CoInitialize method. Calls to these objects from other threads are marshaled to this thread. Only one thread at a time can enter a set of single-threaded objects, and it must be the same thread each time.

The Web server creates a parked thread that calls CoInitialize, and then marshals object calls to itself.

One disadvantage of single-threaded objects is that they cannot be stored in the Application object. The only way to create a single-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 a single-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.