Redigera

Dela via


Choosing the Threading Model

Choosing the threading model for an object depends on the object's function. An object that does extensive I/O might support free-threading to provide maximum response to clients by allowing interface calls during I/O latency. On the other hand, an object that interacts with the user might support apartment threading to synchronize incoming COM calls with its window operations.

It is easier to support apartment threading in single-threaded apartments because COM provides synchronization on a per-call basis. Supporting free-threading is more difficult because the object must implement synchronization; however, response to clients may be better because synchronization can be implemented for smaller sections of code.

Accessing Interfaces Across Apartments

Multithreaded Apartments

In-Process Server Threading Issues

Processes, Threads, and Apartments

Single-Threaded and Multithreaded Communication

Single-Threaded Apartments