EventWaitHandle EventWaitHandle EventWaitHandle EventWaitHandle Class

Définition

Représente un événement de synchronisation de threads.Represents a thread synchronization event.

public ref class EventWaitHandle : System::Threading::WaitHandle
[System.Runtime.InteropServices.ComVisible(true)]
public class EventWaitHandle : System.Threading.WaitHandle
type EventWaitHandle = class
    inherit WaitHandle
Public Class EventWaitHandle
Inherits WaitHandle
Héritage
Attributs

Exemples

L’exemple de code suivant utilise SignalAndWait(WaitHandle, WaitHandle) la surcharge de méthode pour permettre au thread principal de signaler un thread bloqué, puis d’attendre que le thread termine une tâche.The following code example uses the SignalAndWait(WaitHandle, WaitHandle) method overload to allow the main thread to signal a blocked thread and then wait until the thread finishes a task.

L’exemple démarre cinq threads et leur permet de se bloquer EventWaitHandle sur un créé EventResetMode.AutoReset avec l’indicateur, puis libère un thread chaque fois que l’utilisateur appuie sur la touche entrée.The example starts five threads and allows them to block on an EventWaitHandle created with the EventResetMode.AutoReset flag, then releases one thread each time the user presses the ENTER key. L’exemple met ensuite en file d’attente les cinq autres threads et EventWaitHandle les libère tous EventResetMode.ManualReset à l’aide d’un créé avec l’indicateur.The example then queues another five threads and releases them all using an EventWaitHandle created with the EventResetMode.ManualReset flag.

using namespace System;
using namespace System::Threading;

public ref class Example
{
private:
   // The EventWaitHandle used to demonstrate the difference
   // between AutoReset and ManualReset synchronization events.
   //
   static EventWaitHandle^ ewh;

   // A counter to make sure all threads are started and
   // blocked before any are released. A Long is used to show
   // the use of the 64-bit Interlocked methods.
   //
   static __int64 threadCount = 0;

   // An AutoReset event that allows the main thread to block
   // until an exiting thread has decremented the count.
   //
   static EventWaitHandle^ clearCount =
      gcnew EventWaitHandle( false,EventResetMode::AutoReset );

public:
   [MTAThread]
   static void main()
   {
      // Create an AutoReset EventWaitHandle.
      //
      ewh = gcnew EventWaitHandle( false,EventResetMode::AutoReset );
      
      // Create and start five numbered threads. Use the
      // ParameterizedThreadStart delegate, so the thread
      // number can be passed as an argument to the Start
      // method.
      for ( int i = 0; i <= 4; i++ )
      {
         Thread^ t = gcnew Thread(
            gcnew ParameterizedThreadStart( ThreadProc ) );
         t->Start( i );
      }
      
      // Wait until all the threads have started and blocked.
      // When multiple threads use a 64-bit value on a 32-bit
      // system, you must access the value through the
      // Interlocked class to guarantee thread safety.
      //
      while ( Interlocked::Read( threadCount ) < 5 )
      {
         Thread::Sleep( 500 );
      }

      // Release one thread each time the user presses ENTER,
      // until all threads have been released.
      //
      while ( Interlocked::Read( threadCount ) > 0 )
      {
         Console::WriteLine( L"Press ENTER to release a waiting thread." );
         Console::ReadLine();
         
         // SignalAndWait signals the EventWaitHandle, which
         // releases exactly one thread before resetting,
         // because it was created with AutoReset mode.
         // SignalAndWait then blocks on clearCount, to
         // allow the signaled thread to decrement the count
         // before looping again.
         //
         WaitHandle::SignalAndWait( ewh, clearCount );
      }
      Console::WriteLine();
      
      // Create a ManualReset EventWaitHandle.
      //
      ewh = gcnew EventWaitHandle( false,EventResetMode::ManualReset );
      
      // Create and start five more numbered threads.
      //
      for ( int i = 0; i <= 4; i++ )
      {
         Thread^ t = gcnew Thread(
            gcnew ParameterizedThreadStart( ThreadProc ) );
         t->Start( i );
      }
      
      // Wait until all the threads have started and blocked.
      //
      while ( Interlocked::Read( threadCount ) < 5 )
      {
         Thread::Sleep( 500 );
      }

      // Because the EventWaitHandle was created with
      // ManualReset mode, signaling it releases all the
      // waiting threads.
      //
      Console::WriteLine( L"Press ENTER to release the waiting threads." );
      Console::ReadLine();
      ewh->Set();

   }

   static void ThreadProc( Object^ data )
   {
      int index = static_cast<Int32>(data);

      Console::WriteLine( L"Thread {0} blocks.", data );
      // Increment the count of blocked threads.
      Interlocked::Increment( threadCount );
      
      // Wait on the EventWaitHandle.
      ewh->WaitOne();

      Console::WriteLine( L"Thread {0} exits.", data );
      // Decrement the count of blocked threads.
      Interlocked::Decrement( threadCount );
      
      // After signaling ewh, the main thread blocks on
      // clearCount until the signaled thread has
      // decremented the count. Signal it now.
      //
      clearCount->Set();
   }
};
using System;
using System.Threading;

public class Example
{
    // The EventWaitHandle used to demonstrate the difference
    // between AutoReset and ManualReset synchronization events.
    //
    private static EventWaitHandle ewh;

    // A counter to make sure all threads are started and
    // blocked before any are released. A Long is used to show
    // the use of the 64-bit Interlocked methods.
    //
    private static long threadCount = 0;

    // An AutoReset event that allows the main thread to block
    // until an exiting thread has decremented the count.
    //
    private static EventWaitHandle clearCount = 
        new EventWaitHandle(false, EventResetMode.AutoReset);

    [MTAThread]
    public static void Main()
    {
        // Create an AutoReset EventWaitHandle.
        //
        ewh = new EventWaitHandle(false, EventResetMode.AutoReset);

        // Create and start five numbered threads. Use the
        // ParameterizedThreadStart delegate, so the thread
        // number can be passed as an argument to the Start 
        // method.
        for (int i = 0; i <= 4; i++)
        {
            Thread t = new Thread(
                new ParameterizedThreadStart(ThreadProc)
            );
            t.Start(i);
        }

        // Wait until all the threads have started and blocked.
        // When multiple threads use a 64-bit value on a 32-bit
        // system, you must access the value through the
        // Interlocked class to guarantee thread safety.
        //
        while (Interlocked.Read(ref threadCount) < 5)
        {
            Thread.Sleep(500);
        }

        // Release one thread each time the user presses ENTER,
        // until all threads have been released.
        //
        while (Interlocked.Read(ref threadCount) > 0)
        {
            Console.WriteLine("Press ENTER to release a waiting thread.");
            Console.ReadLine();

            // SignalAndWait signals the EventWaitHandle, which
            // releases exactly one thread before resetting, 
            // because it was created with AutoReset mode. 
            // SignalAndWait then blocks on clearCount, to 
            // allow the signaled thread to decrement the count
            // before looping again.
            //
            WaitHandle.SignalAndWait(ewh, clearCount);
        }
        Console.WriteLine();

        // Create a ManualReset EventWaitHandle.
        //
        ewh = new EventWaitHandle(false, EventResetMode.ManualReset);

        // Create and start five more numbered threads.
        //
        for(int i=0; i<=4; i++)
        {
            Thread t = new Thread(
                new ParameterizedThreadStart(ThreadProc)
            );
            t.Start(i);
        }

        // Wait until all the threads have started and blocked.
        //
        while (Interlocked.Read(ref threadCount) < 5)
        {
            Thread.Sleep(500);
        }

        // Because the EventWaitHandle was created with
        // ManualReset mode, signaling it releases all the
        // waiting threads.
        //
        Console.WriteLine("Press ENTER to release the waiting threads.");
        Console.ReadLine();
        ewh.Set();
        
    }

    public static void ThreadProc(object data)
    {
        int index = (int) data;

        Console.WriteLine("Thread {0} blocks.", data);
        // Increment the count of blocked threads.
        Interlocked.Increment(ref threadCount);

        // Wait on the EventWaitHandle.
        ewh.WaitOne();

        Console.WriteLine("Thread {0} exits.", data);
        // Decrement the count of blocked threads.
        Interlocked.Decrement(ref threadCount);

        // After signaling ewh, the main thread blocks on
        // clearCount until the signaled thread has 
        // decremented the count. Signal it now.
        //
        clearCount.Set();
    }
}
Imports System.Threading

Public Class Example

    ' The EventWaitHandle used to demonstrate the difference
    ' between AutoReset and ManualReset synchronization events.
    '
    Private Shared ewh As EventWaitHandle

    ' A counter to make sure all threads are started and
    ' blocked before any are released. A Long is used to show
    ' the use of the 64-bit Interlocked methods.
    '
    Private Shared threadCount As Long = 0

    ' An AutoReset event that allows the main thread to block
    ' until an exiting thread has decremented the count.
    '
    Private Shared clearCount As New EventWaitHandle(False, _
        EventResetMode.AutoReset)

    <MTAThread> _
    Public Shared Sub Main()

        ' Create an AutoReset EventWaitHandle.
        '
        ewh = New EventWaitHandle(False, EventResetMode.AutoReset)

        ' Create and start five numbered threads. Use the
        ' ParameterizedThreadStart delegate, so the thread
        ' number can be passed as an argument to the Start 
        ' method.
        For i As Integer = 0 To 4
            Dim t As New Thread(AddressOf ThreadProc)
            t.Start(i)
        Next i

        ' Wait until all the threads have started and blocked.
        ' When multiple threads use a 64-bit value on a 32-bit
        ' system, you must access the value through the
        ' Interlocked class to guarantee thread safety.
        '
        While Interlocked.Read(threadCount) < 5
            Thread.Sleep(500)
        End While

        ' Release one thread each time the user presses ENTER,
        ' until all threads have been released.
        '
        While Interlocked.Read(threadCount) > 0
            Console.WriteLine("Press ENTER to release a waiting thread.")
            Console.ReadLine()

            ' SignalAndWait signals the EventWaitHandle, which
            ' releases exactly one thread before resetting, 
            ' because it was created with AutoReset mode. 
            ' SignalAndWait then blocks on clearCount, to 
            ' allow the signaled thread to decrement the count
            ' before looping again.
            '
            WaitHandle.SignalAndWait(ewh, clearCount)
        End While
        Console.WriteLine()

        ' Create a ManualReset EventWaitHandle.
        '
        ewh = New EventWaitHandle(False, EventResetMode.ManualReset)

        ' Create and start five more numbered threads.
        '
        For i As Integer = 0 To 4
            Dim t As New Thread(AddressOf ThreadProc)
            t.Start(i)
        Next i

        ' Wait until all the threads have started and blocked.
        '
        While Interlocked.Read(threadCount) < 5
            Thread.Sleep(500)
        End While

        ' Because the EventWaitHandle was created with
        ' ManualReset mode, signaling it releases all the
        ' waiting threads.
        '
        Console.WriteLine("Press ENTER to release the waiting threads.")
        Console.ReadLine()
        ewh.Set()
        
    End Sub

    Public Shared Sub ThreadProc(ByVal data As Object)
        Dim index As Integer = CInt(data)

        Console.WriteLine("Thread {0} blocks.", data)
        ' Increment the count of blocked threads.
        Interlocked.Increment(threadCount)

        ' Wait on the EventWaitHandle.
        ewh.WaitOne()

        Console.WriteLine("Thread {0} exits.", data)
        ' Decrement the count of blocked threads.
        Interlocked.Decrement(threadCount)

        ' After signaling ewh, the main thread blocks on
        ' clearCount until the signaled thread has 
        ' decremented the count. Signal it now.
        '
        clearCount.Set()
    End Sub
End Class

Remarques

La EventWaitHandle classe permet aux threads de communiquer les uns avec les autres en signalant.The EventWaitHandle class allows threads to communicate with each other by signaling. En général, un ou plusieurs threads se EventWaitHandle bloquent sur un, jusqu’à ce Set qu’un thread débloqué appelle la méthode, libérant un ou plusieurs threads bloqués.Typically, one or more threads block on an EventWaitHandle until an unblocked thread calls the Set method, releasing one or more of the blocked threads. Un thread peut signaler un EventWaitHandle , puis le bloquer, en appelant la static méthode (Shared en Visual Basic) WaitHandle.SignalAndWait .A thread can signal an EventWaitHandle and then block on it, by calling the static (Shared in Visual Basic) WaitHandle.SignalAndWait method.

Notes

La EventWaitHandle classe fournit l’accès aux événements de synchronisation système nommés.The EventWaitHandle class provides access to named system synchronization events.

Le comportement d’un EventWaitHandle qui a été signalé dépend de son mode de réinitialisation.The behavior of an EventWaitHandle that has been signaled depends on its reset mode. Un EventWaitHandle créé avec l' EventResetMode.AutoReset indicateur se réinitialise automatiquement quand il est signalé, après avoir libéré un thread en attente unique.An EventWaitHandle created with the EventResetMode.AutoReset flag resets automatically when signaled, after releasing a single waiting thread. Un EventWaitHandle créé avec l’indicateur EventResetMode.ManualReset reste signalé jusqu'à ce que la méthode Reset soit appelée.An EventWaitHandle created with the EventResetMode.ManualReset flag remains signaled until its Reset method is called.

Les événements de réinitialisation automatique offrent un accès exclusif à une ressource.Automatic reset events provide exclusive access to a resource. Si un événement à réinitialisation automatique est signalé alors qu’aucun thread n’attend, il reste signalé jusqu'à ce qu’un thread tente de l’attendre.If an automatic reset event is signaled when no threads are waiting, it remains signaled until a thread attempts to wait on it. L’événement libère le thread et est immédiatement réinitialisé, ce qui bloque les threads suivants.The event releases the thread and immediately resets, blocking subsequent threads.

Les événements de réinitialisation manuelle sont comme les portes.Manual reset events are like gates. Lorsque l’événement n’est pas signalé, les threads qui l’attendent sont bloqués.When the event is not signaled, threads that wait on it will block. Lorsque l’événement est signalé, tous les threads en attente sont libérés et l’événement reste signalé (autrement dit, les attentes suivantes ne sont pas bloquées Reset ) jusqu’à ce que sa méthode soit appelée.When the event is signaled, all waiting threads are released, and the event remains signaled (that is, subsequent waits do not block) until its Reset method is called. Les événements de réinitialisation manuelle sont utiles quand un thread doit terminer une activité avant que d’autres threads puissent continuer.Manual reset events are useful when one thread must complete an activity before other threads can proceed.

EventWaitHandleles objets peuvent être utilisés avec staticlesShared méthodes (dans WaitHandle.WaitAll Visual Basic WaitHandle.WaitAny ) et.EventWaitHandle objects can be used with the static(Shared in Visual Basic) WaitHandle.WaitAll and WaitHandle.WaitAny methods.

Pour plus d’informations, consultez la section interaction des threads ou signalisation de l’article vue d’ensemble des primitives de synchronisation .For more information, see the Thread interaction, or signaling section of the Overview of synchronization primitives article.

Constructeurs

EventWaitHandle(Boolean, EventResetMode) EventWaitHandle(Boolean, EventResetMode) EventWaitHandle(Boolean, EventResetMode) EventWaitHandle(Boolean, EventResetMode)

Initialise une nouvelle instance de la classe EventWaitHandle, en spécifiant si le handle d'attente est signalé initialement et s'il se réinitialise automatiquement ou manuellement.Initializes a new instance of the EventWaitHandle class, specifying whether the wait handle is initially signaled, and whether it resets automatically or manually.

EventWaitHandle(Boolean, EventResetMode, String) EventWaitHandle(Boolean, EventResetMode, String) EventWaitHandle(Boolean, EventResetMode, String) EventWaitHandle(Boolean, EventResetMode, String)

Initialise une nouvelle instance de la classe EventWaitHandle, en spécifiant si le handle d'attente est signalé initialement s'il a été créé à la suite de cet appel, s'il se réinitialise automatiquement ou manuellement, ainsi que le nom d'un événement de synchronisation du système.Initializes a new instance of the EventWaitHandle class, specifying whether the wait handle is initially signaled if created as a result of this call, whether it resets automatically or manually, and the name of a system synchronization event.

EventWaitHandle(Boolean, EventResetMode, String, Boolean) EventWaitHandle(Boolean, EventResetMode, String, Boolean) EventWaitHandle(Boolean, EventResetMode, String, Boolean) EventWaitHandle(Boolean, EventResetMode, String, Boolean)

Initialise une nouvelle instance de la classe EventWaitHandle, spécifiant si le handle d’attente est signalé initialement s’il est créé suite à cet appel, s’il se réinitialise automatiquement ou manuellement, le nom d’un événement de synchronisation du système et une variable booléenne dont la valeur après l’appel indique si l’événement système nommé a été créé.Initializes a new instance of the EventWaitHandle class, specifying whether the wait handle is initially signaled if created as a result of this call, whether it resets automatically or manually, the name of a system synchronization event, and a Boolean variable whose value after the call indicates whether the named system event was created.

EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity)

Initialise une nouvelle instance de la classe EventWaitHandle, spécifiant si le handle d’attente est signalé initialement s’il est créé suite à cet appel, s’il se réinitialise automatiquement ou manuellement, le nom d’un événement de synchronisation du système et une variable booléenne dont la valeur après l’appel indique si l’événement système nommé a été créé, et la sécurité de contrôle d’accès à appliquer à l’événement nommé s’il est créé.Initializes a new instance of the EventWaitHandle class, specifying whether the wait handle is initially signaled if created as a result of this call, whether it resets automatically or manually, the name of a system synchronization event, a Boolean variable whose value after the call indicates whether the named system event was created, and the access control security to be applied to the named event if it is created.

Méthodes

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

Libère toutes les ressources détenues par le WaitHandle actuel.Releases all resources held by the current WaitHandle.

(Inherited from WaitHandle)
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Crée un objet contenant toutes les informations appropriées requises pour générer un proxy permettant de communiquer avec un objet distant.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()

Libère toutes les ressources utilisées par l'instance actuelle de la classe WaitHandle.Releases all resources used by the current instance of the WaitHandle class.

(Inherited from WaitHandle)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

En cas de substitution dans une classe dérivée, libère les ressources non managées utilisées par WaitHandle et libère éventuellement les ressources managées.When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

(Inherited from WaitHandle)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Détermine si l'objet spécifié est identique à l'objet actuel.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAccessControl() GetAccessControl() GetAccessControl() GetAccessControl()

Obtient un objet EventWaitHandleSecurity qui représente la sécurité de contrôle d'accès pour l'événement système nommé représenté par l'objet EventWaitHandle actuel.Gets an EventWaitHandleSecurity object that represents the access control security for the named system event represented by the current EventWaitHandle object.

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

Fait office de fonction de hachage par défaut.Serves as the default hash function.

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

Récupère l'objet de service de durée de vie en cours qui contrôle la stratégie de durée de vie de cette instance.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

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

Obtient le Type de l'instance actuelle.Gets the Type of the current instance.

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

Obtient un objet de service de durée de vie pour contrôler la stratégie de durée de vie de cette instance.Obtains a lifetime service object to control the lifetime policy for this instance.

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

Crée une copie superficielle de l'objet Object actuel.Creates a shallow copy of the current Object.

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

Crée une copie superficielle de l'objet MarshalByRefObject actuel.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OpenExisting(String) OpenExisting(String) OpenExisting(String) OpenExisting(String)

Ouvre l'événement de synchronisation nommé spécifié s'il existe déjà.Opens the specified named synchronization event, if it already exists.

OpenExisting(String, EventWaitHandleRights) OpenExisting(String, EventWaitHandleRights) OpenExisting(String, EventWaitHandleRights) OpenExisting(String, EventWaitHandleRights)

Ouvre l'événement de synchronisation nommé spécifié, s'il existe déjà, avec l'accès de sécurité souhaité.Opens the specified named synchronization event, if it already exists, with the desired security access.

Reset() Reset() Reset() Reset()

Définit l'état de l'événement comme étant non signalé, entraînant le blocage des threads.Sets the state of the event to nonsignaled, causing threads to block.

Set() Set() Set() Set()

Définit l'état de l'événement comme étant signalé, ce qui permet à un ou plusieurs threads en attente de continuer.Sets the state of the event to signaled, allowing one or more waiting threads to proceed.

SetAccessControl(EventWaitHandleSecurity) SetAccessControl(EventWaitHandleSecurity) SetAccessControl(EventWaitHandleSecurity) SetAccessControl(EventWaitHandleSecurity)

Définit la sécurité de contrôle d'accès pour un événement système nommé.Sets the access control security for a named system event.

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

Retourne une chaîne qui représente l'objet actuel.Returns a string that represents the current object.

(Inherited from Object)
TryOpenExisting(String, EventWaitHandle) TryOpenExisting(String, EventWaitHandle) TryOpenExisting(String, EventWaitHandle) TryOpenExisting(String, EventWaitHandle)

Ouvre l’événement de synchronisation nommé spécifié, s’il existe déjà, et retourne une valeur indiquant si l’opération a réussi.Opens the specified named synchronization event, if it already exists, and returns a value that indicates whether the operation succeeded.

TryOpenExisting(String, EventWaitHandleRights, EventWaitHandle) TryOpenExisting(String, EventWaitHandleRights, EventWaitHandle) TryOpenExisting(String, EventWaitHandleRights, EventWaitHandle) TryOpenExisting(String, EventWaitHandleRights, EventWaitHandle)

Ouvre l'événement de synchronisation nommé spécifié, s'il existe déjà, avec l'accès de sécurité souhaité, puis retourne une valeur indiquant si l'opération a réussi.Opens the specified named synchronization event, if it already exists, with the desired security access, and returns a value that indicates whether the operation succeeded.

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

Bloque le thread actuel jusqu'à ce que le WaitHandle actuel reçoive un signal.Blocks the current thread until the current WaitHandle receives a signal.

(Inherited from WaitHandle)
WaitOne(Int32) WaitOne(Int32) WaitOne(Int32) WaitOne(Int32)

Bloque le thread actuel jusqu'à ce que le WaitHandle actuel reçoive un signal, en utilisant un entier signé 32 bits pour spécifier l'intervalle de temps.Blocks the current thread until the current WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval in milliseconds.

(Inherited from WaitHandle)
WaitOne(Int32, Boolean) WaitOne(Int32, Boolean) WaitOne(Int32, Boolean) WaitOne(Int32, Boolean)

Bloque le thread actuel jusqu’à ce que le WaitHandle actuel reçoive un signal, en utilisant un entier signé 32 bits pour spécifier l’intervalle de temps et en spécifiant s’il faut quitter le domaine de synchronisation avant l’attente.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.

(Inherited from WaitHandle)
WaitOne(TimeSpan) WaitOne(TimeSpan) WaitOne(TimeSpan) WaitOne(TimeSpan)

Bloque le thread actuel jusqu'à ce que l'instance actuelle reçoive un signal, en utilisant une valeur TimeSpan pour spécifier l'intervalle de temps.Blocks the current thread until the current instance receives a signal, using a TimeSpan to specify the time interval.

(Inherited from WaitHandle)
WaitOne(TimeSpan, Boolean) WaitOne(TimeSpan, Boolean) WaitOne(TimeSpan, Boolean) WaitOne(TimeSpan, Boolean)

Bloque le thread actuel jusqu'à ce que l'instance actuelle reçoive un signal, en utilisant une valeur TimeSpan pour spécifier l'intervalle de temps et en spécifiant s'il faut quitter le domaine de synchronisation avant l'attente.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.

(Inherited from WaitHandle)

Propriétés

Handle Handle Handle Handle

Obtient ou définit le handle du système d'exploitation natif.Gets or sets the native operating system handle.

(Inherited from WaitHandle)
SafeWaitHandle SafeWaitHandle SafeWaitHandle SafeWaitHandle

Obtient ou définit le handle du système d'exploitation natif.Gets or sets the native operating system handle.

(Inherited from WaitHandle)

Implémentations d’interfaces explicites

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

Libère toutes les ressources utilisées par WaitHandle.Releases all resources used by the WaitHandle.

(Inherited from WaitHandle)

Champs

WaitTimeout WaitTimeout WaitTimeout WaitTimeout

Indique que le délai fixé pour une opération WaitAny(WaitHandle[], Int32, Boolean) a été dépassé sans qu'aucun des handles d'attente n'ait été signalé.Indicates that a WaitAny(WaitHandle[], Int32, Boolean) operation timed out before any of the wait handles were signaled. Ce champ est constant.This field is constant.

(Inherited from WaitHandle)

Méthodes d’extension

GetAccessControl(EventWaitHandle) GetAccessControl(EventWaitHandle) GetAccessControl(EventWaitHandle) GetAccessControl(EventWaitHandle)
SetAccessControl(EventWaitHandle, EventWaitHandleSecurity) SetAccessControl(EventWaitHandle, EventWaitHandleSecurity) SetAccessControl(EventWaitHandle, EventWaitHandleSecurity) SetAccessControl(EventWaitHandle, EventWaitHandleSecurity)
GetSafeWaitHandle(WaitHandle) GetSafeWaitHandle(WaitHandle) GetSafeWaitHandle(WaitHandle) GetSafeWaitHandle(WaitHandle)

Obtient le handle sécurisé pour un handle d’attente de système d’exploitation natif.Gets the safe handle for a native operating system wait handle.

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

Définit un handle sécurisé pour un handle d’attente de système d’exploitation natif.Sets a safe handle for a native operating system wait handle.

S’applique à

Cohérence de thread

Ce type est thread-safe.This type is thread safe.

Voir aussi