Inproc Object Custom Interface in Apartment Model Client

ID: Q137629

4.00    | 3.51
WINDOWS | WINDOWS NT kbole kbprg

The information in this article applies to:

SUMMARY

Single threaded inproc objects (not marked with a ThreadingModel value), must provide marshaling code for any custom interfaces that they may implement.

MORE INFORMATION

An OLE inproc object that is not marked with the ThreadingModel value in the system registry is considered single threaded.

When an apartment model threaded client creates instances of this inproc object in its different threads, OLE cannot load the objects into those threads. This is because the object is single threaded and is not designed for multithreaded access by a client. Instead, OLE will instantiate the object in the main apartment (thread) of the client. (The main apartment is the thread that first called Co/OleIntialize.) The object will be marshaled to the other threads of the client that require use of it. This marshaling requires the inproc object to provide marshaling code for any custom interfaces it may implement. (The MIDL compiler can be used to generate marshaling code.)

If this inproc object doesn't provide marshaling code for its custom interfaces, it can be used only by single threaded clients or by clients that use the object only from the main apartment.

An object that is marked ThreadingModel=Apartment or ThreadingModel=Both is apartment model-aware. When an apartment model threaded client creates instances of this inproc object in its different threads, each instance will be instantiated in the respective apartments. Consequently the object need not provide marshaling code for any custom interfaces that it may implement.

Additional reference words: 4.00 CreateThread 32 bit KBCategory: kbole kbprg KBSubcategory: LeTwoArc

Keywords          : LeTwoArc 
Version           : 4.00    | 3.51
Platform          : NT WINDOWS

Last Reviewed: July 26, 1996