Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))

MTAThread Attribute

Class

System.MTAThreadAttribute

Applies To

Method

Constructor

New( )

Properties

None defined

Description

The <MTAThread> attribute indicates that the application to which the program element belongs uses the multithreaded apartment model for COM interop. The attribute should be applied to the application's Main method or subroutine. This attribute only applies to applications that use COM interop.

The <MTAThread> attribute is similar to setting a System.Threading.Thread object's ApartmentState property to ApartmentState.MTA. The difference is that the <MTAThread> attribute creates a multithreaded apartment at startup, while setting the property does it only from the point that the property is set.

See Also

STAThread Attribute

Категории