HostProtectionAttribute.ExternalThreading 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否公开外部线程处理。
public:
property bool ExternalThreading { bool get(); void set(bool value); };
public bool ExternalThreading { get; set; }
member this.ExternalThreading : bool with get, set
Public Property ExternalThreading As Boolean
属性值
如果公开外部线程处理,则为 true
;否则为 false
。 默认值为 false
。
示例
下面的代码示例演示如何将 特性与 属性一 HostProtectionAttribute 起使用 ExternalThreading 。 此示例是为 类提供的更大示例的一 HostProtectionAttribute 部分。
// Use the enumeration flags to indicate that this method exposes synchronization
// and external threading.
[HostProtection(Synchronization=true,ExternalThreading=true)]
static void StartThread()
{
Thread^ t = gcnew Thread( gcnew ThreadStart( WatchFileEvents ) );
// Start the new thread. On a uniprocessor, the thread is not given
// any processor time until the main thread yields the processor.
t->Start();
// Give the new thread a chance to execute.
Thread::Sleep( 1000 );
}
// Use the enumeration flags to indicate that this method exposes
// synchronization and external threading.
[HostProtectionAttribute(Synchronization=true, ExternalThreading=true)]
private static void StartThread()
{
Thread t = new Thread(new ThreadStart(WatchFileEvents));
// Start the new thread. On a uniprocessor, the thread is not given
// any processor time until the main thread yields the processor.
t.Start();
// Give the new thread a chance to execute.
Thread.Sleep(1000);
}
' Use the enumeration flags to indicate that this method exposes
' synchronization and external threading.
<HostProtectionAttribute(Synchronization := True, _
ExternalThreading := True)> _
Private Shared Sub StartThread()
Dim t As New Thread(New ThreadStart(AddressOf WatchFileEvents))
' Start the new thread. On a uniprocessor, the thread is not given
' any processor time until the main thread yields the processor.
t.Start()
' Give the new thread a chance to execute.
Thread.Sleep(1000)
End Sub
注解
公开外部线程的代码创建或操作自身以外的线程,这可能会对主机有害。