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

설명

외부 스레딩을 노출하는 코드는 호스트에 해로울 수 있는 자체 스레드 이외의 스레드를 만들거나 조작합니다.

적용 대상

추가 정보