System.Object System.Attribute System.STAThreadAttribute[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线程安全 此类型的所有公共静态(Visual Basic 中为 Shared)成员对多线程操作而言都是安全的。但不保证任何实例成员是线程安全的。备注 COM 线程模型只适用于使用 COM interop 的应用程序。如果将此属性应用到不使用 COM interop 的应用程序,将没有任何效果。COM 线程模型可设置为单线程单元或多线程单元。如果应用程序线程实际调用了 COM 组件,则仅为 COM interop 初始化该线程。如果没有使用 COM interop,则不初始化该线程。此属性与设置 System.Threading.Thread 的 System.Threading.ApartmentState 属性具有相同的效果。为确保线程模型在执行任何启动代码之前已被设置,请应用该属性,而不要设置 ApartmentState 属性。
System.Attribute
System.STAThreadAttribute[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线程安全
此类型的所有公共静态(Visual Basic 中为 Shared)成员对多线程操作而言都是安全的。但不保证任何实例成员是线程安全的。备注
COM 线程模型只适用于使用 COM interop 的应用程序。如果将此属性应用到不使用 COM interop 的应用程序,将没有任何效果。COM 线程模型可设置为单线程单元或多线程单元。如果应用程序线程实际调用了 COM 组件,则仅为 COM interop 初始化该线程。如果没有使用 COM interop,则不初始化该线程。此属性与设置 System.Threading.Thread 的 System.Threading.ApartmentState 属性具有相同的效果。为确保线程模型在执行任何启动代码之前已被设置,请应用该属性,而不要设置 ApartmentState 属性。