Indicates that the COM threading model for an application is single-threaded apartment (STA).
For a list of all members of this type, see STAThreadAttribute Members.
[Visual Basic] <AttributeUsage(AttributeTargets.Method)> NotInheritable Public Class STAThreadAttribute Inherits Attribute [C#] [AttributeUsage(AttributeTargets.Method)] public sealed class STAThreadAttribute : Attribute [C++] [AttributeUsage(AttributeTargets::Method)] public __gc __sealed class STAThreadAttribute : public Attribute [JScript] public AttributeUsage(AttributeTargets.Method) class STAThreadAttribute extends Attribute
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.
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)