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
繼承
衍生
屬性
實作

範例

下列程式碼範例顯示兩個執行緒如何執行背景工作,而主執行緒會使用WaitAny WaitHandle類別的靜態和WaitAll方法來等候工作完成。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.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
    
    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
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呼叫實例方法,這是由衍生WaitHandle自的類別繼承而來。Threads 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 的執行緒必須釋放它,而且如果執行緒在未擁有的 mutex 上呼叫ReleaseMutex方法,則會擲回例外狀況。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.

因為類別衍生自MarshalByRefObject,所以這些類別可以用來跨應用程式域界限同步處理執行緒的活動。 WaitHandleBecause 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. 若要直接處置型別,請呼叫其 try/catch 區塊中的 Close 方法。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.

WaitHandleDispose執行模式。WaitHandle implements the Dispose pattern. 請參閱 [執行 Dispose 方法] (~/docs/standard/garbage-collection/implementing-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否則不需要覆寫受保護的方法。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.

擴充方法

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.

另請參閱