System.Win.ComObj.TThreadingModel

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

TThreadingModel = (tmSingle, tmApartment, tmFree, tmBoth, tmNeutral);

C++

enum DECLSPEC_DENUM TThreadingModel : unsigned char { tmSingle, tmApartment, tmFree, tmBoth, tmNeutral };

Properties

Type Visibility Source Unit Parent
enum public
System.Win.ComObj.pas
System.Win.ComObj.hpp
System.Win.ComObj System.Win.ComObj

Description

TThreadingModel indicates how COM serializes calls to a COM object.

ThreadingModel determines how COM serializes calls to a COM object. The application must ensure that the COM object implementation can safely handle the specified threading model.

The following table lists the possible values for TThreadingModel.



Value Meaning

tmSingle

COM serializes all client requests. The object does not need to provide thread support.

tmApartment

COM ensures that any instance of the COM object services one request at a time. Different objects from the same server can be called on different threads, but each object is called only from that one thread. Instance data is safe, global data must be protected using critical sections or some other form of serialization. The thread's local variables are reliable across multiple calls.

tmFree

Also called multi-threaded apartment. The COM object can receive calls from any thread at any time. Objects must protect all instance and global data using critical sections or some other form of serialization. Thread local variables are not reliable across multiple calls.

tmBoth

Objects can support clients that use either apartment or free threading models. It supports both threading models when clients may be using either single-threaded or free threading models.

tmNeutral

Multiple clients can call the object on different threads at the same time, but COM ensures that no two calls conflict. You must guard against thread conflicts involving global data and any instance data that is accessed by more than one method. This model should not be used with objects that have a user interface. This model is only available under COM+. Under COM, it is mapped to the Apartment model.