This documentation is archived and is not being maintained.

MTAThreadAttribute Class

Indicates that the COM threading model for an application is multithreaded apartment (MTA).

For a list of all members of this type, see MTAThreadAttribute Members.


[Visual Basic]
NotInheritable Public Class MTAThreadAttribute
   Inherits Attribute
public sealed class MTAThreadAttribute : Attribute
public __gc __sealed class MTAThreadAttribute : public Attribute
class MTAThreadAttribute extends Attribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


COM threading models only pertain to applications that use COM interop. Using this attribute in an application that does not use COM interop has no effect.

The COM threading model can be set to single-threaded apartment or multithreaded apartment. The application thread is only initialized for COM interop if the thread actually makes a call to a COM component. If COM interop is not used, then the thread is not initialized.

This attribute has the same effect as setting the System.Threading.ApartmentState property of a System.Threading.Thread. Apply this attribute, rather than set the ApartmentState property, to ensure the threading model is set before any startup code is executed.

Apply this attribute to the main method of an application.

Note   ASP.Net applications should set the ASPCompat attribute of the @ Page directive to true, to force the page to be serviced by the STA thread pool.


Namespace: System

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

MTAThreadAttribute Members | System Namespace | STAThreadAttribute