WaitHandle WaitHandle WaitHandle WaitHandle Class

定義

將等候共用資源獨佔存取權限的特定作業系統物件封裝起來。Encapsulates operating system-specific objects that wait for exclusive access to shared resources.

public ref class WaitHandle abstract : MarshalByRefObject, IDisposable
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class WaitHandle : MarshalByRefObject, IDisposable
type WaitHandle = class
    inherit MarshalByRefObject
    interface IDisposable
Public MustInherit Class WaitHandle
Inherits MarshalByRefObject
Implements IDisposable
繼承
衍生
屬性
實作

範例

下列程式碼範例示範如何在兩個執行緒可以執行背景工作,並在主要執行緒等候工作完成使用靜態WaitAnyWaitAll方法WaitHandle類別。The following code example shows how two threads can do background tasks while the Main thread waits for the tasks to complete using the static WaitAny and WaitAll methods of the WaitHandle class.

using namespace System;
using namespace System::Threading;

public ref class WaitHandleExample
{
    // Define a random number generator for testing.
private:
    static Random^ random = gcnew Random();
public:
    static void DoTask(Object^ state)
    {
        AutoResetEvent^ autoReset = (AutoResetEvent^) state;
        int time = 1000 * random->Next(2, 10);
        Console::WriteLine("Performing a task for {0} milliseconds.", time);
        Thread::Sleep(time);
        autoReset->Set();
    }
};

int main()
{
    // Define an array with two AutoResetEvent WaitHandles.
    array<WaitHandle^>^ handles = gcnew array<WaitHandle^> {
        gcnew AutoResetEvent(false), gcnew AutoResetEvent(false)};

    // Queue up two tasks on two different threads;
    // wait until all tasks are completed.
    DateTime timeInstance = DateTime::Now;
    Console::WriteLine("Main thread is waiting for BOTH tasks to " +
        "complete.");
    ThreadPool::QueueUserWorkItem(
        gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]);
    ThreadPool::QueueUserWorkItem(
        gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]);
    WaitHandle::WaitAll(handles);
    // The time shown below should match the longest task.
    Console::WriteLine("Both tasks are completed (time waited={0})",
        (DateTime::Now - timeInstance).TotalMilliseconds);

    // Queue up two tasks on two different threads;
    // wait until any tasks are completed.
    timeInstance = DateTime::Now;
    Console::WriteLine();
    Console::WriteLine("The main thread is waiting for either task to " +
        "complete.");
    ThreadPool::QueueUserWorkItem(
        gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]);
    ThreadPool::QueueUserWorkItem(
        gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]);
    int index = WaitHandle::WaitAny(handles);
    // The time shown below should match the shortest task.
    Console::WriteLine("Task {0} finished first (time waited={1}).",
        index + 1, (DateTime::Now - timeInstance).TotalMilliseconds);
}

// This code produces the following sample output.
//
// Main thread is waiting for BOTH tasks to complete.
// Performing a task for 7000 milliseconds.
// Performing a task for 4000 milliseconds.
// Both tasks are completed (time waited=7064.8052)

// The main thread is waiting for either task to complete.
// Performing a task for 2000 milliseconds.
// Performing a task for 2000 milliseconds.
// Task 1 finished first (time waited=2000.6528).
using System;
using System.Threading;

public sealed class App 
{
    // Define an array with two AutoResetEvent WaitHandles.
    static WaitHandle[] waitHandles = new WaitHandle[] 
    {
        new AutoResetEvent(false),
        new AutoResetEvent(false)
    };

    // Define a random number generator for testing.
    static Random r = new Random();

    static void Main() 
    {
        // Queue up two tasks on two different threads; 
        // wait until all tasks are completed.
        DateTime dt = DateTime.Now;
        Console.WriteLine("Main thread is waiting for BOTH tasks to complete.");
        ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
        ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
        WaitHandle.WaitAll(waitHandles);
        // The time shown below should match the longest task.
        Console.WriteLine("Both tasks are completed (time waited={0})", 
            (DateTime.Now - dt).TotalMilliseconds);

        // Queue up two tasks on two different threads; 
        // wait until any tasks are completed.
        dt = DateTime.Now;
        Console.WriteLine();
        Console.WriteLine("The main thread is waiting for either task to complete.");
        ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
        ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
        int index = WaitHandle.WaitAny(waitHandles);
        // The time shown below should match the shortest task.
        Console.WriteLine("Task {0} finished first (time waited={1}).",
            index + 1, (DateTime.Now - dt).TotalMilliseconds);
    }

    static void DoTask(Object state) 
    {
        AutoResetEvent are = (AutoResetEvent) state;
        int time = 1000 * r.Next(2, 10);
        Console.WriteLine("Performing a task for {0} milliseconds.", time);
        Thread.Sleep(time);
        are.Set();
    }
}

// This code produces output similar to the following:
//
//  Main thread is waiting for BOTH tasks to complete.
//  Performing a task for 7000 milliseconds.
//  Performing a task for 4000 milliseconds.
//  Both tasks are completed (time waited=7064.8052)
// 
//  The main thread is waiting for either task to complete.
//  Performing a task for 2000 milliseconds.
//  Performing a task for 2000 milliseconds.
//  Task 1 finished first (time waited=2000.6528).
Imports System
Imports System.Threading

NotInheritable Public Class App
    ' Define an array with two AutoResetEvent WaitHandles.
    Private Shared waitHandles() As WaitHandle = _
        {New AutoResetEvent(False), New AutoResetEvent(False)}
    
    ' Define a random number generator for testing.
    Private Shared r As New Random()
    
    <MTAThreadAttribute> _
    Public Shared Sub Main() 
        ' Queue two tasks on two different threads; 
        ' wait until all tasks are completed.
        Dim dt As DateTime = DateTime.Now
        Console.WriteLine("Main thread is waiting for BOTH tasks to complete.")
        ThreadPool.QueueUserWorkItem(AddressOf DoTask, waitHandles(0))
        ThreadPool.QueueUserWorkItem(AddressOf DoTask, waitHandles(1))
        WaitHandle.WaitAll(waitHandles)
        ' The time shown below should match the longest task.
        Console.WriteLine("Both tasks are completed (time waited={0})", _
            (DateTime.Now - dt).TotalMilliseconds)
        
        ' Queue up two tasks on two different threads; 
        ' wait until any tasks are completed.
        dt = DateTime.Now
        Console.WriteLine()
        Console.WriteLine("The main thread is waiting for either task to complete.")
        ThreadPool.QueueUserWorkItem(AddressOf DoTask, waitHandles(0))
        ThreadPool.QueueUserWorkItem(AddressOf DoTask, waitHandles(1))
        Dim index As Integer = WaitHandle.WaitAny(waitHandles)
        ' The time shown below should match the shortest task.
        Console.WriteLine("Task {0} finished first (time waited={1}).", _
            index + 1,(DateTime.Now - dt).TotalMilliseconds)
    
    End Sub 'Main
    
    Shared Sub DoTask(ByVal state As [Object]) 
        Dim are As AutoResetEvent = CType(state, AutoResetEvent)
        Dim time As Integer = 1000 * r.Next(2, 10)
        Console.WriteLine("Performing a task for {0} milliseconds.", time)
        Thread.Sleep(time)
        are.Set()
    
    End Sub 'DoTask
End Class 'App

' This code produces output similar to the following:
'
'  Main thread is waiting for BOTH tasks to complete.
'  Performing a task for 7000 milliseconds.
'  Performing a task for 4000 milliseconds.
'  Both tasks are completed (time waited=7064.8052)
' 
'  The main thread is waiting for either task to complete.
'  Performing a task for 2000 milliseconds.
'  Performing a task for 2000 milliseconds.
'  Task 1 finished first (time waited=2000.6528).

備註

WaitHandle類別封裝原生作業系統同步處理控制代碼,而且用來代表所有在執行階段允許多個等候作業的同步處理物件。The WaitHandle class encapsulates a native operating system synchronization handle and is used to represent all synchronization objects in the runtime that allow multiple wait operations. 如需與其他同步處理物件的等候控制代碼的比較,請參閱 < 同步處理原始物件概觀For a comparison of wait handles with other synchronization objects, see Overview of Synchronization Primitives.

WaitHandle本身的類別是抽象的。The WaitHandle class itself is abstract. 類別衍生自WaitHandle定義訊號的機制,以指示耗時或釋放存取共用資源,但是會使用繼承WaitHandle方法來封鎖而等待存取共用資源。Classes derived from WaitHandle define a signaling mechanism to indicate taking or releasing access to a shared resource, but they use the inherited WaitHandle methods to block while waiting for access to shared resources. 類別衍生自WaitHandle包括:The classes derived from WaitHandle include:

個別的等候控制代碼上封鎖執行緒,可以將它所呼叫的執行個體方法WaitOne,其中會由衍生自的類別繼承WaitHandleThreads can block on an individual wait handle by calling the instance method WaitOne, which is inherited by classes derived from WaitHandle.

在衍生的類別WaitHandle的差異在於其執行緒親和性。The derived classes of WaitHandle differ in their thread affinity. 事件等候控制代碼 (EventWaitHandleAutoResetEvent,和ManualResetEvent),號誌沒有執行緒相似性; 任何執行緒可以發出信號的事件等候控制代碼或號誌。Event wait handles (EventWaitHandle, AutoResetEvent, and ManualResetEvent) and semaphores do not have thread affinity; any thread can signal an event wait handle or semaphore. Mutex,相反地,沒有執行緒相似性;擁有 mutex 的執行緒必須釋放它,並會擲回例外狀況,如果執行緒呼叫ReleaseMutex上未擁有 mutex 的方法。Mutexes, on the other hand, do have thread affinity; the thread that owns a mutex must release it, and an exception is thrown if a thread calls the ReleaseMutex method on a mutex that it does not own.

因為WaitHandle類別衍生自MarshalByRefObject,這些類別可以用來跨應用程式定義域界限同步處理執行緒的活動。Because the WaitHandle class derives from MarshalByRefObject, these classes can be used to synchronize the activities of threads across application domain boundaries.

除了其衍生的類別,WaitHandle類別具有一些靜態方法,封鎖執行緒,直到其中一個或多個同步物件收到信號。In addition to its derived classes, the WaitHandle class has a number of static methods that block a thread until one or more synchronization objects receive a signal. 它們包括:These include:

  • SignalAndWait這可讓發出信號一個等候控制代碼,以及立即等候另一個執行緒。SignalAndWait, which allows a thread to signal one wait handle and immediately wait on another.

  • WaitAll這可讓執行緒等候,直到在陣列中的所有等候控制代碼會都收到信號。WaitAll, which allows a thread to wait until all the wait handles in an array receive a signal.

  • WaitAny這可讓執行緒等候,直到收到訊號的一組指定的等候控制代碼的任何一個。WaitAny, which allows a thread to wait until any one of a specified set of wait handles has been signaled.

這些方法的多載提供放棄等候,並有機會先離開同步處理內容,再進入等候,讓其他執行緒使用的同步處理內容的逾時間隔。The overloads of these methods provide timeout intervals for abandoning the wait, and the opportunity to exit a synchronization context before entering the wait, allowing other threads to use the synchronization context.

重要

此類型會實作IDisposable介面。This type implements the IDisposable interface. 當您完成使用的類型或從中衍生的類型時,您應該處置它直接或間接。When you have finished using the type or a type derived from it, you should dispose of it either directly or indirectly. 若要直接處置型別,呼叫其Close方法中的try / catch區塊。To dispose of the type directly, call its Close method in a try/catch block. 若要處置它間接,使用的語言建構這類using(在 C# 中) 或Using(在 Visual Basic)。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 如需詳細資訊,請參閱 「 使用物件,實作 IDisposable 」 一節IDisposable介面 > 主題。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

WaitHandle 實作Dispose模式。WaitHandle implements the Dispose pattern. 請參閱 實作 Dispose 方法See [Implementing a Dispose method](~/docs/standard/garbage-collection/implementing-dispose .md). 當您衍生自WaitHandle,使用SafeWaitHandle屬性來儲存您的原生作業系統控制代碼。When you derive from WaitHandle, use the SafeWaitHandle property to store your native operating system handle. 您不需要覆寫保護Dispose方法除非您使用其他的 unmanaged 的資源。You do not need to override the protected Dispose method unless you use additional unmanaged resources.

建構函式

WaitHandle() WaitHandle() WaitHandle() WaitHandle()

初始化 WaitHandle 類別的新執行個體。Initializes a new instance of the WaitHandle class.

欄位

InvalidHandle InvalidHandle InvalidHandle InvalidHandle

代表無效的原生作業系統控制代碼。Represents an invalid native operating system handle. 此欄位為唯讀。This field is read-only.

WaitTimeout WaitTimeout WaitTimeout WaitTimeout

表示 WaitAny(WaitHandle[], Int32, Boolean) 作業在發出任何等候控制代碼信號之前便已逾時。Indicates that a WaitAny(WaitHandle[], Int32, Boolean) operation timed out before any of the wait handles were signaled. 這個欄位是常數。This field is constant.

屬性

Handle Handle Handle Handle

取得或設定原生 (Native) 的作業系統控制代碼。Gets or sets the native operating system handle.

SafeWaitHandle SafeWaitHandle SafeWaitHandle SafeWaitHandle

取得或設定原生 (Native) 的作業系統控制代碼。Gets or sets the native operating system handle.

方法

Close() Close() Close() Close()

釋放目前 WaitHandle 所持有的全部資源。Releases all resources held by the current WaitHandle.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

釋放 WaitHandle 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the WaitHandle class.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

當在衍生類別中覆寫時,釋放 WaitHandle 所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

將目前執行個體所持有的資源釋出。Releases the resources held by the current instance.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle) SignalAndWait(WaitHandle, WaitHandle)

發出一個 WaitHandle 信號並等候另一個。Signals one WaitHandle and waits on another.

SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean) SignalAndWait(WaitHandle, WaitHandle, Int32, Boolean)

發出一個 WaitHandle 信號並等候另一個,將逾時間隔指定為 32 位元帶正負號的整數,並指定是否要先離開內容的同步處理網域,再進入等候狀態。Signals one WaitHandle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait.

SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean) SignalAndWait(WaitHandle, WaitHandle, TimeSpan, Boolean)

發出一個 WaitHandle 信號並等候另一個,將逾時間隔指定為 TimeSpan,並指定是否要先離開內容的同步處理網域,再進入等候狀態。Signals one WaitHandle and waits on another, specifying the time-out interval as a TimeSpan and specifying whether to exit the synchronization domain for the context before entering the wait.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
WaitAll(WaitHandle[]) WaitAll(WaitHandle[]) WaitAll(WaitHandle[]) WaitAll(WaitHandle[])

等候指定陣列中的所有項目都收到信號。Waits for all the elements in the specified array to receive a signal.

WaitAll(WaitHandle[], Int32) WaitAll(WaitHandle[], Int32) WaitAll(WaitHandle[], Int32) WaitAll(WaitHandle[], Int32)

等候指定陣列中的所有項目都收到信號,使用 Int32 值來指定時間間隔。Waits for all the elements in the specified array to receive a signal, using an Int32 value to specify the time interval.

WaitAll(WaitHandle[], Int32, Boolean) WaitAll(WaitHandle[], Int32, Boolean) WaitAll(WaitHandle[], Int32, Boolean) WaitAll(WaitHandle[], Int32, Boolean)

等候指定陣列中的所有項目都收到信號,使用 Int32 值來指定時間間隔,並指定是否要先離開同步處理網域,再開始等候。Waits for all the elements in the specified array to receive a signal, using an Int32 value to specify the time interval and specifying whether to exit the synchronization domain before the wait.

WaitAll(WaitHandle[], TimeSpan) WaitAll(WaitHandle[], TimeSpan) WaitAll(WaitHandle[], TimeSpan) WaitAll(WaitHandle[], TimeSpan)

等候指定陣列中的所有項目都收到信號,使用 TimeSpan 值來指定時間間隔。Waits for all the elements in the specified array to receive a signal, using a TimeSpan value to specify the time interval.

WaitAll(WaitHandle[], TimeSpan, Boolean) WaitAll(WaitHandle[], TimeSpan, Boolean) WaitAll(WaitHandle[], TimeSpan, Boolean) WaitAll(WaitHandle[], TimeSpan, Boolean)

等候指定陣列中的所有項目都收到信號,使用 TimeSpan 值來指定時間間隔,並指定是否要先離開同步處理網域,再開始等候。Waits for all the elements in the specified array to receive a signal, using a TimeSpan value to specify the time interval, and specifying whether to exit the synchronization domain before the wait.

WaitAny(WaitHandle[]) WaitAny(WaitHandle[]) WaitAny(WaitHandle[]) WaitAny(WaitHandle[])

等候指定陣列中有任何項目收到信號。Waits for any of the elements in the specified array to receive a signal.

WaitAny(WaitHandle[], Int32) WaitAny(WaitHandle[], Int32) WaitAny(WaitHandle[], Int32) WaitAny(WaitHandle[], Int32)

等候指定之陣列中有任何項目收到信號,使用 32 位元帶正負號的整數以指定時間間隔。Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval.

WaitAny(WaitHandle[], Int32, Boolean) WaitAny(WaitHandle[], Int32, Boolean) WaitAny(WaitHandle[], Int32, Boolean) WaitAny(WaitHandle[], Int32, Boolean)

等候指定陣列中有任何項目收到信號;使用 32 位元帶正負號的整數 (Signed Integer) 來指定時間間隔,並指定是否在等候之前先離開同步處理領域。Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval, and specifying whether to exit the synchronization domain before the wait.

WaitAny(WaitHandle[], TimeSpan) WaitAny(WaitHandle[], TimeSpan) WaitAny(WaitHandle[], TimeSpan) WaitAny(WaitHandle[], TimeSpan)

等候指定陣列中的所有項目都收到信號,使用 TimeSpan 來指定時間間隔。Waits for any of the elements in the specified array to receive a signal, using a TimeSpan to specify the time interval.

WaitAny(WaitHandle[], TimeSpan, Boolean) WaitAny(WaitHandle[], TimeSpan, Boolean) WaitAny(WaitHandle[], TimeSpan, Boolean) WaitAny(WaitHandle[], TimeSpan, Boolean)

等候指定陣列中的所有項目都收到信號,使用 TimeSpan 來指定時間間隔,並指定是否要先離開同步處理網域,再開始等候。Waits for any of the elements in the specified array to receive a signal, using a TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait.

WaitOne() WaitOne() WaitOne() WaitOne()

封鎖目前的執行緒,直到目前的 WaitHandle 收到訊號為止。Blocks the current thread until the current WaitHandle receives a signal.

WaitOne(Int32) WaitOne(Int32) WaitOne(Int32) WaitOne(Int32)

封鎖目前執行緒,直到目前的 WaitHandle 收到信號為止,使用 32 位元帶正負號的整數來指定時間間隔 (以毫秒為單位)。Blocks the current thread until the current WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval in milliseconds.

WaitOne(Int32, Boolean) WaitOne(Int32, Boolean) WaitOne(Int32, Boolean) WaitOne(Int32, Boolean)

封鎖目前執行緒,直到目前的 WaitHandle 收到信號為止,使用 32 位元帶正負號的整數來指定時間間隔,並指定是否要先離開同步處理網域,再開始等候。Blocks the current thread until the current WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval and specifying whether to exit the synchronization domain before the wait.

WaitOne(TimeSpan) WaitOne(TimeSpan) WaitOne(TimeSpan) WaitOne(TimeSpan)

封鎖目前執行緒,直到目前執行個體收到信號為止,使用 TimeSpan 來指定時間間隔。Blocks the current thread until the current instance receives a signal, using a TimeSpan to specify the time interval.

WaitOne(TimeSpan, Boolean) WaitOne(TimeSpan, Boolean) WaitOne(TimeSpan, Boolean) WaitOne(TimeSpan, Boolean)

封鎖目前執行緒,直到目前執行個體收到信號為止,使用 TimeSpan 來指定時間間隔,並指定是否要先離開同步處理網域,再開始等候。Blocks the current thread until the current instance receives a signal, using a TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait.

明確介面實作

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

釋放 WaitHandle 所使用的所有資源。Releases all resources used by the WaitHandle.

Extension Methods

GetSafeWaitHandle(WaitHandle) GetSafeWaitHandle(WaitHandle) GetSafeWaitHandle(WaitHandle) GetSafeWaitHandle(WaitHandle)

取得原生作業系統等候控制代碼的安全控制代碼。Gets the safe handle for a native operating system wait handle.

SetSafeWaitHandle(WaitHandle, SafeWaitHandle) SetSafeWaitHandle(WaitHandle, SafeWaitHandle) SetSafeWaitHandle(WaitHandle, SafeWaitHandle) SetSafeWaitHandle(WaitHandle, SafeWaitHandle)

設定原生作業系統等候控制代碼的安全控制代碼。Sets a safe handle for a native operating system wait handle.

適用於

執行緒安全性

此型別具備執行緒安全。This type is thread safe.

另請參閱