HostProtectionAttribute.ExternalThreading プロパティ

定義

外部スレッド処理が公開されているかどうかを示す値を取得または設定します。

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

プロパティ値

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

注釈

外部スレッドを公開するコードは、独自のスレッド以外のスレッドを作成または操作します。これは、ホストに悪影響を受ける可能性があります。

適用対象

こちらもご覧ください