Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.91 KB

threading-cpp.md

File metadata and controls

65 lines (43 loc) · 1.91 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: threading (C++)
threading (C++ COM Attribute)
10/02/2018
vc-attr.threading
threading attribute
9b558cd6-fbf0-4602-aed5-31c068550ce3

threading (C++)

Specifies the threading model for a COM object.

Syntax

[ threading(model=enumeration) ]

Parameters

model
(Optional) One of the following threading models:

  • apartment (apartment threading)

  • neutral (.NET Framework components with no user interface)

  • single (simple threading)

  • free (free threading)

  • both (apartment and free threading)

The default value is apartment.

Remarks

The threading C++ attribute does not appear in the generated .idl file but will be used in the implementation of your COM object.

In ATL projects, If the coclass attribute is also present, the threading model specified by model is passed as the template parameter to the CComObjectRootEx class, inserted by the coclass attribute.

The threading attribute also guards access to an event_source.

Example

See the licensed example for a sample use of threading.

Requirements

Attribute context Value
Applies to class, struct
Repeatable No
Required attributes coclass
Invalid attributes None

For more information about the attribute contexts, see Attribute Contexts.

See also

COM Attributes
Typedef, Enum, Union, and Struct Attributes
Class Attributes
Multithreading Support for Older Code (Visual C++)
Neutral Apartments