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/0 latency. On the other hand, an object that interacts with the user might support apartment threading to synchronize incoming OLE calls with its window operations.

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