EventWaitHandle 생성자

정의

EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

오버로드

EventWaitHandle(Boolean, EventResetMode)

대기 핸들의 초기 상태를 신호 받음으로 설정할지 여부와 대기 핸들을 자동으로 다시 설정할지 수동으로 다시 설정할지 여부를 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

EventWaitHandle(Boolean, EventResetMode, String)

이 호출의 결과로 만들어진 대기 핸들의 초기 상태를 신호 받음으로 설정할지 여부, 대기 핸들을 자동으로 다시 설정할지 수동으로 다시 설정할지 여부 및 시스템 동기화 이벤트의 이름을 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

EventWaitHandle(Boolean, EventResetMode, String, Boolean)

이 호출의 결과로 대기 핸들이 초기에 신호를 받는지 여부, 자동으로 재설정되는지 또는 수동으로 재설정되는지, 시스템 동기화 이벤트의 이름, 호출 후에 해당 값이 명명된 시스템 이벤트가 생성되었는지 여부를 나타내는 부울 변수를 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

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

이 호출의 결과로 대기 핸들이 초기에 신호를 받는지 여부, 자동으로 재설정되는지 또는 수동으로 재설정되는지, 시스템 동기화 이벤트의 이름, 호출 후에 해당 값이 명명된 시스템 이벤트가 생성되었는지 여부를 나타내는 부울 변수, 생성되는 경우 명명된 이벤트에 적용될 액세스 제어 보안을 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

EventWaitHandle(Boolean, EventResetMode)

대기 핸들의 초기 상태를 신호 받음으로 설정할지 여부와 대기 핸들을 자동으로 다시 설정할지 수동으로 다시 설정할지 여부를 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

public:
 EventWaitHandle(bool initialState, System::Threading::EventResetMode mode);
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode);
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode -> System.Threading.EventWaitHandle
Public Sub New (initialState As Boolean, mode As EventResetMode)

매개 변수

initialState
Boolean

초기 상태를 신호 받음으로 설정하려면 true를 사용하고 초기 상태를 신호 없음으로 설정하려면 false를 사용합니다.

mode
EventResetMode

이벤트가 자동으로 다시 설정되는지 또는 수동으로 다시 설정되는지를 결정하는 EventResetMode 값 중 하나입니다.

예외

mode 열거형 값이 올바른 범위를 벗어납니다.

예제

다음 코드 예제에서는 메서드 오버로드를 사용하여 SignalAndWait(WaitHandle, WaitHandle) 기본 스레드가 차단된 스레드에 신호를 보냅니다. 그런 다음 스레드가 작업을 완료할 때까지 기다립니다.

이 예제에서는 5개의 스레드를 시작하고 플래그를 사용하여 만든 EventResetMode.AutoReset 스레드에서 EventWaitHandle 차단한 다음 사용자가 Enter 키를 누를 때마다 스레드 하나를 해제할 수 있습니다. 그런 다음, 이 예제에서는 다른 5개의 스레드를 큐에 대기시키고 플래그를 사용하여 만든 EventResetMode.ManualResetEventWaitHandle 사용하여 모두 해제합니다.

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

설명

이벤트의 초기 상태가 서명되지 않은 경우 이벤트를 기다리는 스레드가 차단됩니다. 초기 상태가 신호를 받고 플래그가 ManualResetmode대해 지정된 경우 이벤트를 기다리는 스레드는 차단되지 않습니다. 초기 상태가 신호이고 modeAutoReset가 이면 이벤트를 기다리는 첫 번째 스레드가 즉시 해제되고, 그 후에는 이벤트가 다시 설정되고 후속 스레드가 차단됩니다.

추가 정보

적용 대상

EventWaitHandle(Boolean, EventResetMode, String)

이 호출의 결과로 만들어진 대기 핸들의 초기 상태를 신호 받음으로 설정할지 여부, 대기 핸들을 자동으로 다시 설정할지 수동으로 다시 설정할지 여부 및 시스템 동기화 이벤트의 이름을 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

public:
 EventWaitHandle(bool initialState, System::Threading::EventResetMode mode, System::String ^ name);
[System.Security.SecurityCritical]
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string name);
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string? name);
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string name);
[<System.Security.SecurityCritical>]
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode * string -> System.Threading.EventWaitHandle
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode * string -> System.Threading.EventWaitHandle
Public Sub New (initialState As Boolean, mode As EventResetMode, name As String)

매개 변수

initialState
Boolean

명명된 이벤트가 이 호출의 결과로 만들어지는 경우 초기 상태를 signaled로 설정하려면 true이고, nonsignaled로 설정하려면 false입니다.

mode
EventResetMode

이벤트가 자동으로 다시 설정되는지 또는 수동으로 다시 설정되는지를 결정하는 EventResetMode 값 중 하나입니다.

name
String

동기화 개체를 다른 프로세스와 공유할 예정이면 이름이고, 그렇지 않으면 null 또는 빈 문자열입니다. 이름은 대/소문자를 구분합니다. 백슬래시 문자(\)는 예약되어 있으며 네임스페이스를 지정하는 데만 사용할 수 있습니다. 네임스페이스에 대한 자세한 내용은 설명 섹션을 참조하세요. 운영 체제에 따라 이름에 대한 추가 제한이 있을 수 있습니다. 예를 들어 Unix 기반 운영 체제에서 네임스페이스를 제외한 후의 이름은 유효한 파일 이름이어야 합니다.

특성

예외

name이 잘못되었습니다. 이유는 다양하며, 대표적인 이유는 운영 체제가 적용하는 일부 제한(예: 알 수 없는 접두사나 잘못된 문자)입니다. 이름 및 일반 접두사 "Global\" 및 "Local\"은 대/소문자를 구분합니다.

-또는-

다른 오류가 발생했습니다. HResult 속성에서 자세한 정보를 확인할 수 있습니다.

Windows에만 해당: name이 알 수 없는 네임스페이스를 지정했습니다. 자세한 내용은 개체 이름을 참조하세요.

name이 너무 깁니다. 길이 제한은 운영 체제나 구성에 따라 달라집니다.

명명된 이벤트가 존재하고 이 뮤텍스에 액세스 제어 보안이 있지만, 사용자에게 FullControl이 없는 경우

이름이 name인 동기화 개체를 만들 수 없습니다. 다른 형식의 동기화 개체에 동일한 이름이 사용되었을 수 있습니다.

mode 열거형 값이 올바른 범위를 벗어납니다.

-또는-

.NET Framework에만 해당: name이 MAX_PATH(260자)보다 깁니다.

설명

name 접두사를 추가 Global\ 하거나 Local\ 네임스페이스를 지정할 수 있습니다. 네임스페이 Global 스를 지정하면 동기화 개체를 시스템의 모든 프로세스와 공유할 수 있습니다. Local 네임스페이스를 지정하면 네임스페이스가 지정되지 않은 경우에도 기본값으로 동기화 개체를 동일한 세션의 프로세스와 공유할 수 있습니다. Windows에서 세션은 로그인 세션이며 서비스는 일반적으로 다른 비대화형 세션에서 실행됩니다. Unix와 유사한 운영 체제에서 각 셸에는 자체 세션이 있습니다. 세션 로컬 동기화 개체는 모두 동일한 세션에서 실행되는 부모/자식 관계와 프로세스 간의 동기화에 적합할 수 있습니다. Windows의 동기화 개체 이름에 대한 자세한 내용은 개체 이름을 참조하세요.

name 제공되고 요청된 형식의 동기화 개체가 네임스페이스에 이미 있는 경우 기존 동기화 개체가 열립니다. 다른 형식의 동기화 개체가 네임스페이스에 WaitHandleCannotBeOpenedException 이미 있는 경우 이 throw됩니다. 그렇지 않으면 새 동기화 개체가 만들어집니다.

매개 변수에 대해 name 지정된 이름의 시스템 이벤트가 이미 있는 initialState 경우 매개 변수는 무시됩니다.

주의

기본적으로 명명된 이벤트는 이벤트를 만든 사용자로 제한되지 않습니다. 다른 사용자는 이벤트를 설정하거나 부적절하게 다시 설정하여 이벤트를 방해하는 등 이벤트를 열고 사용할 수 있습니다. 특정 사용자에 대한 액세스를 제한하려면 생성자 오버로드를 사용하거나 EventWaitHandleAcl 명명된 이벤트를 만들 때 를 전달할 EventWaitHandleSecurity 수 있습니다. 신뢰할 수 없는 사용자가 코드를 실행 중일 수 있는 시스템에 대한 액세스 제한 없이 명명된 이벤트를 사용하지 마세요.

중요

명명된 시스템 이벤트에 이 생성자를 사용하는 경우 에 를 지정 false 합니다 initialState. 이 생성자는 명명된 시스템 이벤트가 만들어졌는지 여부를 확인할 수 없으므로 명명된 이벤트의 상태에 대해 어떠한 가정도 할 수 없습니다. 명명된 이벤트가 만들어졌는지 여부를 확인하려면 생성자 또는 EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) 생성자를 사용합니다EventWaitHandle(Boolean, EventResetMode, String, Boolean).

이벤트의 초기 상태가 서명되지 않은 경우 이벤트를 기다리는 스레드가 차단됩니다. 초기 상태가 신호를 받고 플래그가 ManualResetmode대해 지정된 경우 이벤트를 기다리는 스레드는 차단되지 않습니다. 초기 상태가 신호이고 modeAutoReset가 이면 이벤트를 기다리는 첫 번째 스레드가 즉시 해제되고, 그 후에는 이벤트가 다시 설정되고 후속 스레드가 차단됩니다.

추가 정보

적용 대상

EventWaitHandle(Boolean, EventResetMode, String, Boolean)

이 호출의 결과로 대기 핸들이 초기에 신호를 받는지 여부, 자동으로 재설정되는지 또는 수동으로 재설정되는지, 시스템 동기화 이벤트의 이름, 호출 후에 해당 값이 명명된 시스템 이벤트가 생성되었는지 여부를 나타내는 부울 변수를 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

public:
 EventWaitHandle(bool initialState, System::Threading::EventResetMode mode, System::String ^ name, [Runtime::InteropServices::Out] bool % createdNew);
[System.Security.SecurityCritical]
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string name, out bool createdNew);
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string? name, out bool createdNew);
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string name, out bool createdNew);
[<System.Security.SecurityCritical>]
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode * string * bool -> System.Threading.EventWaitHandle
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode * string * bool -> System.Threading.EventWaitHandle
Public Sub New (initialState As Boolean, mode As EventResetMode, name As String, ByRef createdNew As Boolean)

매개 변수

initialState
Boolean

명명된 이벤트가 이 호출의 결과로 만들어지는 경우 초기 상태를 signaled로 설정하려면 true이고, nonsignaled로 설정하려면 false입니다.

mode
EventResetMode

이벤트가 자동으로 다시 설정되는지 또는 수동으로 다시 설정되는지를 결정하는 EventResetMode 값 중 하나입니다.

name
String

동기화 개체를 다른 프로세스와 공유할 예정이면 이름이고, 그렇지 않으면 null 또는 빈 문자열입니다. 이름은 대/소문자를 구분합니다. 백슬래시 문자(\)는 예약되어 있으며 네임스페이스를 지정하는 데만 사용할 수 있습니다. 네임스페이스에 대한 자세한 내용은 설명 섹션을 참조하세요. 운영 체제에 따라 이름에 대한 추가 제한이 있을 수 있습니다. 예를 들어 Unix 기반 운영 체제에서 네임스페이스를 제외한 후의 이름은 유효한 파일 이름이어야 합니다.

createdNew
Boolean

이 메서드가 반환될 때 로컬 이벤트가 만들어지거나(nametrue 또는 빈 문자열) 명명된 지정 시스템 이벤트가 만들어지면 null가 포함되고 명명된 지정 시스템 이벤트가 이미 있으면 false가 포함됩니다. 이 매개 변수는 초기화되지 않은 상태로 전달됩니다.

특성

예외

name이 잘못되었습니다. 이유는 다양하며, 대표적인 이유는 운영 체제가 적용하는 일부 제한(예: 알 수 없는 접두사나 잘못된 문자)입니다. 이름 및 일반 접두사 "Global\" 및 "Local\"은 대/소문자를 구분합니다.

-또는-

다른 오류가 발생했습니다. HResult 속성에서 자세한 정보를 확인할 수 있습니다.

Windows에만 해당: name이 알 수 없는 네임스페이스를 지정했습니다. 자세한 내용은 개체 이름을 참조하세요.

name이 너무 깁니다. 길이 제한은 운영 체제나 구성에 따라 달라집니다.

명명된 이벤트가 존재하고 이 뮤텍스에 액세스 제어 보안이 있지만, 사용자에게 FullControl이 없는 경우

이름이 name인 동기화 개체를 만들 수 없습니다. 다른 형식의 동기화 개체에 동일한 이름이 사용되었을 수 있습니다.

mode 열거형 값이 올바른 범위를 벗어납니다.

-또는-

.NET Framework에만 해당: name이 MAX_PATH(260자)보다 깁니다.

설명

name 접두사를 추가 Global\ 하거나 Local\ 네임스페이스를 지정할 수 있습니다. 네임스페이 Global 스를 지정하면 동기화 개체를 시스템의 모든 프로세스와 공유할 수 있습니다. Local 네임스페이스를 지정하면 네임스페이스가 지정되지 않은 경우에도 기본값이 되며, 동기화 개체를 동일한 세션의 프로세스와 공유할 수 있습니다. Windows에서 세션은 로그인 세션이며 서비스는 일반적으로 다른 비대화형 세션에서 실행됩니다. Unix와 유사한 운영 체제에서 각 셸에는 자체 세션이 있습니다. 세션-로컬 동기화 개체는 모두 동일한 세션에서 실행되는 부모/자식 관계와 프로세스 간의 동기화에 적합할 수 있습니다. Windows의 동기화 개체 이름에 대한 자세한 내용은 개체 이름을 참조하세요.

name 제공되고 요청된 형식의 동기화 개체가 네임스페이스에 이미 있는 경우 기존 동기화 개체가 열립니다. 다른 형식의 동기화 개체가 네임스페이스에 이미 있는 경우 이 WaitHandleCannotBeOpenedException throw됩니다. 그렇지 않으면 새 동기화 개체가 만들어집니다.

매개 변수에 대해 name 지정된 이름의 시스템 이벤트가 이미 있는 initialState 경우 매개 변수는 무시됩니다. 이 생성자를 호출한 후 매개 변수(ByRefVisual Basic의 매개 변수)createdNewref 지정된 변수의 값을 사용하여 명명된 시스템 이벤트가 이미 있는지 또는 만들어졌는지 확인합니다.

이벤트의 초기 상태가 서명되지 않은 경우 이벤트를 대기하는 스레드가 차단됩니다. 초기 상태가 신호를 받고 플래그가 ManualResetmode대해 지정된 경우 이벤트를 기다리는 스레드는 차단되지 않습니다. 초기 상태가 신호이고 modeAutoReset면 이벤트를 대기하는 첫 번째 스레드가 즉시 해제되고 그 후에 이벤트가 다시 설정되고 후속 스레드가 차단됩니다.

주의

기본적으로 명명된 이벤트는 이벤트를 만든 사용자로 제한되지 않습니다. 다른 사용자는 이벤트를 설정하거나 부적절하게 다시 설정하여 이벤트를 방해하는 등 이벤트를 열고 사용할 수 있습니다. 특정 사용자에 대한 액세스를 제한하려면 생성자 오버로드를 사용하거나 EventWaitHandleAcl 명명된 이벤트를 만들 때 를 EventWaitHandleSecurity 전달하면 됩니다. 신뢰할 수 없는 사용자가 코드를 실행 중일 수 있는 시스템에 액세스 제한 없이 명명된 이벤트를 사용하지 마세요.

추가 정보

적용 대상

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

이 호출의 결과로 대기 핸들이 초기에 신호를 받는지 여부, 자동으로 재설정되는지 또는 수동으로 재설정되는지, 시스템 동기화 이벤트의 이름, 호출 후에 해당 값이 명명된 시스템 이벤트가 생성되었는지 여부를 나타내는 부울 변수, 생성되는 경우 명명된 이벤트에 적용될 액세스 제어 보안을 지정하여 EventWaitHandle 클래스의 새 인스턴스를 초기화합니다.

public:
 EventWaitHandle(bool initialState, System::Threading::EventResetMode mode, System::String ^ name, [Runtime::InteropServices::Out] bool % createdNew, System::Security::AccessControl::EventWaitHandleSecurity ^ eventSecurity);
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string name, out bool createdNew, System.Security.AccessControl.EventWaitHandleSecurity eventSecurity);
[System.Security.SecurityCritical]
public EventWaitHandle (bool initialState, System.Threading.EventResetMode mode, string name, out bool createdNew, System.Security.AccessControl.EventWaitHandleSecurity eventSecurity);
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode * string * bool * System.Security.AccessControl.EventWaitHandleSecurity -> System.Threading.EventWaitHandle
[<System.Security.SecurityCritical>]
new System.Threading.EventWaitHandle : bool * System.Threading.EventResetMode * string * bool * System.Security.AccessControl.EventWaitHandleSecurity -> System.Threading.EventWaitHandle
Public Sub New (initialState As Boolean, mode As EventResetMode, name As String, ByRef createdNew As Boolean, eventSecurity As EventWaitHandleSecurity)

매개 변수

initialState
Boolean

명명된 이벤트가 이 호출의 결과로 만들어지는 경우 초기 상태를 signaled로 설정하려면 true이고, nonsignaled로 설정하려면 false입니다.

mode
EventResetMode

이벤트가 자동으로 다시 설정되는지 또는 수동으로 다시 설정되는지를 결정하는 EventResetMode 값 중 하나입니다.

name
String

동기화 개체를 다른 프로세스와 공유할 예정이면 이름이고, 그렇지 않으면 null 또는 빈 문자열입니다. 이름은 대/소문자를 구분합니다. 백슬래시 문자(\)는 예약되어 있으며 네임스페이스를 지정하는 데만 사용할 수 있습니다. 네임스페이스에 대한 자세한 내용은 설명 섹션을 참조하세요. 운영 체제에 따라 이름에 대한 추가 제한이 있을 수 있습니다. 예를 들어 Unix 기반 운영 체제에서 네임스페이스를 제외한 후의 이름은 유효한 파일 이름이어야 합니다.

createdNew
Boolean

이 메서드가 반환될 때 로컬 이벤트가 만들어지거나(nametrue 또는 빈 문자열) 명명된 지정 시스템 이벤트가 만들어지면 null가 포함되고 명명된 지정 시스템 이벤트가 이미 있으면 false가 포함됩니다. 이 매개 변수는 초기화되지 않은 상태로 전달됩니다.

eventSecurity
EventWaitHandleSecurity

명명된 시스템 이벤트에 적용할 액세스 제어 보안을 나타내는 EventWaitHandleSecurity 개체입니다.

특성

예외

name이 잘못되었습니다. 이유는 다양하며, 대표적인 이유는 운영 체제가 적용하는 일부 제한(예: 알 수 없는 접두사나 잘못된 문자)입니다. 이름 및 일반 접두사 "Global\" 및 "Local\"은 대/소문자를 구분합니다.

-또는-

다른 오류가 발생했습니다. HResult 속성에서 자세한 정보를 확인할 수 있습니다.

Windows에만 해당: name이 알 수 없는 네임스페이스를 지정했습니다. 자세한 내용은 개체 이름을 참조하세요.

name이 너무 깁니다. 길이 제한은 운영 체제나 구성에 따라 달라집니다.

명명된 이벤트가 존재하고 이 뮤텍스에 액세스 제어 보안이 있지만, 사용자에게 FullControl이 없는 경우

이름이 name인 동기화 개체를 만들 수 없습니다. 다른 형식의 동기화 개체에 동일한 이름이 사용되었을 수 있습니다.

mode 열거형 값이 올바른 범위를 벗어납니다.

-또는-

.NET Framework에만 해당: name이 MAX_PATH(260자)보다 깁니다.

예제

다음 코드 예제에서는 액세스 제어 보안을 사용하여 명명된 시스템 이벤트의 교차 프로세스 동작을 보여 줍니다. 이 예제에서는 메서드 오버로드를 OpenExisting(String) 사용하여 명명된 이벤트의 존재를 테스트합니다.

이벤트가 없는 경우 현재 사용자에게 이벤트를 사용할 수 있는 권한을 거부하지만 이벤트에 대한 읽기 및 변경 권한을 부여하는 초기 소유권 및 액세스 제어 보안을 사용하여 생성됩니다.

두 명령 창에서 컴파일된 예제를 실행하는 경우 두 번째 복사본은 에 대한 호출 OpenExisting(String)에서 액세스 위반 예외를 throw합니다. 예외가 catch되고, 이 예제에서는 메서드 오버로드를 사용하여 OpenExisting(String, EventWaitHandleRights) 권한을 읽고 변경하는 데 필요한 권한으로 이벤트를 기다립니다.

사용 권한이 변경된 후에는 이벤트를 기다렸다가 신호를 전송하는 데 필요한 권한으로 이벤트가 열립니다. 세 번째 명령 창에서 컴파일된 예제를 실행하는 경우 예제는 새 권한을 사용하여 실행됩니다.

using namespace System;
using namespace System::Threading;
using namespace System::Security::AccessControl;
using namespace System::Security::Permissions;

public ref class Example
{
public:
   [SecurityPermissionAttribute(SecurityAction::Demand,Flags=SecurityPermissionFlag::UnmanagedCode)]
   static void Main()
   {
      String^ ewhName = L"EventWaitHandleExample5";

      EventWaitHandle^ ewh = nullptr;
      bool doesNotExist = false;
      bool unauthorized = false;
      
      // The value of this variable is set by the event
      // constructor. It is true if the named system event was
      // created, and false if the named event already existed.
      //
      bool wasCreated;
      
      // Attempt to open the named event.
      try
      {
         // Open the event with (EventWaitHandleRights.Synchronize
         // | EventWaitHandleRights.Modify), to wait on and
         // signal the named event.
         //
         ewh = EventWaitHandle::OpenExisting( ewhName );
      }
      catch ( WaitHandleCannotBeOpenedException^ ) 
      {
         Console::WriteLine( L"Named event does not exist." );
         doesNotExist = true;
      }
      catch ( UnauthorizedAccessException^ ex ) 
      {
         Console::WriteLine( L"Unauthorized access: {0}", ex->Message );
         unauthorized = true;
      }

      // There are three cases: (1) The event does not exist.
      // (2) The event exists, but the current user doesn't
      // have access. (3) The event exists and the user has
      // access.
      //
      if ( doesNotExist )
      {
         // The event does not exist, so create it.

         // Create an access control list (ACL) that denies the
         // current user the right to wait on or signal the
         // event, but allows the right to read and change
         // security information for the event.
         //
         String^ user = String::Concat( Environment::UserDomainName, L"\\",
            Environment::UserName );
         EventWaitHandleSecurity^ ewhSec = gcnew EventWaitHandleSecurity;
         //following constructor fails
         EventWaitHandleAccessRule^ rule = gcnew EventWaitHandleAccessRule(
            user,
            static_cast<EventWaitHandleRights>(
               EventWaitHandleRights::Synchronize | 
               EventWaitHandleRights::Modify),
            AccessControlType::Deny );
         ewhSec->AddAccessRule( rule );

         rule = gcnew EventWaitHandleAccessRule( user,
            static_cast<EventWaitHandleRights>(
               EventWaitHandleRights::ReadPermissions | 
               EventWaitHandleRights::ChangePermissions),
            AccessControlType::Allow );
         ewhSec->AddAccessRule( rule );
         
         // Create an EventWaitHandle object that represents
         // the system event named by the constant 'ewhName',
         // initially signaled, with automatic reset, and with
         // the specified security access. The Boolean value that
         // indicates creation of the underlying system object
         // is placed in wasCreated.
         //
         ewh = gcnew EventWaitHandle( true,
            EventResetMode::AutoReset,
            ewhName,
            wasCreated,
            ewhSec );
         
         // If the named system event was created, it can be
         // used by the current instance of this program, even
         // though the current user is denied access. The current
         // program owns the event. Otherwise, exit the program.
         //
         if ( wasCreated )
         {
            Console::WriteLine( L"Created the named event." );
         }
         else
         {
            Console::WriteLine( L"Unable to create the event." );
            return;
         }
      }
      else if ( unauthorized )
      {
         // Open the event to read and change the access control
         // security. The access control security defined above
         // allows the current user to do this.
         //
         try
         {
            ewh = EventWaitHandle::OpenExisting( ewhName, 
               static_cast<EventWaitHandleRights>(
                  EventWaitHandleRights::ReadPermissions |
                  EventWaitHandleRights::ChangePermissions) );
            
            // Get the current ACL. This requires
            // EventWaitHandleRights.ReadPermissions.
            EventWaitHandleSecurity^ ewhSec = ewh->GetAccessControl();
            String^ user = String::Concat( Environment::UserDomainName, L"\\",
               Environment::UserName );
            
            // First, the rule that denied the current user
            // the right to enter and release the event must
            // be removed.
            EventWaitHandleAccessRule^ rule = gcnew EventWaitHandleAccessRule(
               user,
               static_cast<EventWaitHandleRights>(
                  EventWaitHandleRights::Synchronize |
                  EventWaitHandleRights::Modify),
               AccessControlType::Deny );
            ewhSec->RemoveAccessRule( rule );
            
            // Now grant the user the correct rights.
            //
            rule = gcnew EventWaitHandleAccessRule( user,
               static_cast<EventWaitHandleRights>(
                  EventWaitHandleRights::Synchronize |
                  EventWaitHandleRights::Modify),
               AccessControlType::Allow );
            ewhSec->AddAccessRule( rule );
            
            // Update the ACL. This requires
            // EventWaitHandleRights.ChangePermissions.
            ewh->SetAccessControl( ewhSec );
            Console::WriteLine( L"Updated event security." );
            
            // Open the event with (EventWaitHandleRights.Synchronize
            // | EventWaitHandleRights.Modify), the rights required
            // to wait on and signal the event.
            //
            ewh = EventWaitHandle::OpenExisting( ewhName );
         }
         catch ( UnauthorizedAccessException^ ex ) 
         {
            Console::WriteLine( L"Unable to change permissions: {0}",
               ex->Message );
            return;
         }

      }
      
      // Wait on the event, and hold it until the program
      // exits.
      //
      try
      {
         Console::WriteLine( L"Wait on the event." );
         ewh->WaitOne();
         Console::WriteLine( L"Event was signaled." );
         Console::WriteLine( L"Press the Enter key to signal the event and exit." );
         Console::ReadLine();
      }
      catch ( UnauthorizedAccessException^ ex ) 
      {
         Console::WriteLine( L"Unauthorized access: {0}", ex->Message );
      }
      finally
      {
         ewh->Set();
      }
   }
};

int main()
{
   Example::Main();
}
using System;
using System.Threading;
using System.Security.AccessControl;

internal class Example
{
    internal static void Main()
    {
        const string ewhName = "EventWaitHandleExample5";

        EventWaitHandle ewh = null;
        bool doesNotExist = false;
        bool unauthorized = false;

        // The value of this variable is set by the event
        // constructor. It is true if the named system event was
        // created, and false if the named event already existed.
        //
        bool wasCreated;

        // Attempt to open the named event.
        try
        {
            // Open the event with (EventWaitHandleRights.Synchronize
            // | EventWaitHandleRights.Modify), to wait on and 
            // signal the named event.
            //
            ewh = EventWaitHandle.OpenExisting(ewhName);
        }
        catch (WaitHandleCannotBeOpenedException)
        {
            Console.WriteLine("Named event does not exist.");
            doesNotExist = true;
        }
        catch (UnauthorizedAccessException ex)
        {
            Console.WriteLine("Unauthorized access: {0}", ex.Message);
            unauthorized = true;
        }

        // There are three cases: (1) The event does not exist.
        // (2) The event exists, but the current user doesn't 
        // have access. (3) The event exists and the user has
        // access.
        //
        if (doesNotExist)
        {
            // The event does not exist, so create it.

            // Create an access control list (ACL) that denies the
            // current user the right to wait on or signal the 
            // event, but allows the right to read and change
            // security information for the event.
            //
            string user = Environment.UserDomainName + "\\"
                + Environment.UserName;
            EventWaitHandleSecurity ewhSec = 
                new EventWaitHandleSecurity();

            EventWaitHandleAccessRule rule = 
                new EventWaitHandleAccessRule(user, 
                    EventWaitHandleRights.Synchronize | 
                    EventWaitHandleRights.Modify, 
                    AccessControlType.Deny);
            ewhSec.AddAccessRule(rule);

            rule = new EventWaitHandleAccessRule(user, 
                EventWaitHandleRights.ReadPermissions | 
                EventWaitHandleRights.ChangePermissions, 
                AccessControlType.Allow);
            ewhSec.AddAccessRule(rule);

            // Create an EventWaitHandle object that represents
            // the system event named by the constant 'ewhName', 
            // initially signaled, with automatic reset, and with
            // the specified security access. The Boolean value that 
            // indicates creation of the underlying system object
            // is placed in wasCreated.
            //
            ewh = new EventWaitHandle(true, 
                EventResetMode.AutoReset, 
                ewhName, 
                out wasCreated, 
                ewhSec);

            // If the named system event was created, it can be
            // used by the current instance of this program, even 
            // though the current user is denied access. The current
            // program owns the event. Otherwise, exit the program.
            // 
            if (wasCreated)
            {
                Console.WriteLine("Created the named event.");
            }
            else
            {
                Console.WriteLine("Unable to create the event.");
                return;
            }
        }
        else if (unauthorized)
        {
            // Open the event to read and change the access control
            // security. The access control security defined above
            // allows the current user to do this.
            //
            try
            {
                ewh = EventWaitHandle.OpenExisting(ewhName, 
                    EventWaitHandleRights.ReadPermissions | 
                    EventWaitHandleRights.ChangePermissions);

                // Get the current ACL. This requires 
                // EventWaitHandleRights.ReadPermissions.
                EventWaitHandleSecurity ewhSec = ewh.GetAccessControl();
                
                string user = Environment.UserDomainName + "\\"
                    + Environment.UserName;

                // First, the rule that denied the current user 
                // the right to enter and release the event must
                // be removed.
                EventWaitHandleAccessRule rule = 
                    new EventWaitHandleAccessRule(user, 
                        EventWaitHandleRights.Synchronize | 
                        EventWaitHandleRights.Modify, 
                        AccessControlType.Deny);
                ewhSec.RemoveAccessRule(rule);

                // Now grant the user the correct rights.
                // 
                rule = new EventWaitHandleAccessRule(user, 
                    EventWaitHandleRights.Synchronize | 
                    EventWaitHandleRights.Modify, 
                    AccessControlType.Allow);
                ewhSec.AddAccessRule(rule);

                // Update the ACL. This requires
                // EventWaitHandleRights.ChangePermissions.
                ewh.SetAccessControl(ewhSec);

                Console.WriteLine("Updated event security.");

                // Open the event with (EventWaitHandleRights.Synchronize 
                // | EventWaitHandleRights.Modify), the rights required
                // to wait on and signal the event.
                //
                ewh = EventWaitHandle.OpenExisting(ewhName);
            }
            catch (UnauthorizedAccessException ex)
            {
                Console.WriteLine("Unable to change permissions: {0}",
                    ex.Message);
                return;
            }
        }

        // Wait on the event, and hold it until the program
        // exits.
        //
        try
        {
            Console.WriteLine("Wait on the event.");
            ewh.WaitOne();
            Console.WriteLine("Event was signaled.");
            Console.WriteLine("Press the Enter key to signal the event and exit.");
            Console.ReadLine();
        }
        catch (UnauthorizedAccessException ex)
        {
            Console.WriteLine("Unauthorized access: {0}", ex.Message);
        }
        finally
        {
            ewh.Set();
        }
    }
}
Imports System.Threading
Imports System.Security.AccessControl

Friend Class Example

    <MTAThread> _
    Friend Shared Sub Main()
        Const ewhName As String = "EventWaitHandleExample5"

        Dim ewh As EventWaitHandle = Nothing
        Dim doesNotExist as Boolean = False
        Dim unauthorized As Boolean = False

        ' The value of this variable is set by the event
        ' constructor. It is True if the named system event was
        ' created, and False if the named event already existed.
        '
        Dim wasCreated As Boolean

        ' Attempt to open the named event.
        Try
            ' Open the event with (EventWaitHandleRights.Synchronize
            ' Or EventWaitHandleRights.Modify), to wait on and 
            ' signal the named event.
            '
            ewh = EventWaitHandle.OpenExisting(ewhName)
        Catch ex As WaitHandleCannotBeOpenedException
            Console.WriteLine("Named event does not exist.")
            doesNotExist = True
        Catch ex As UnauthorizedAccessException
            Console.WriteLine("Unauthorized access: {0}", ex.Message)
            unauthorized = True
        End Try

        ' There are three cases: (1) The event does not exist.
        ' (2) The event exists, but the current user doesn't 
        ' have access. (3) The event exists and the user has
        ' access.
        '
        If doesNotExist Then
            ' The event does not exist, so create it.

            ' Create an access control list (ACL) that denies the
            ' current user the right to wait on or signal the 
            ' event, but allows the right to read and change
            ' security information for the event.
            '
            Dim user As String = Environment.UserDomainName _ 
                & "\" & Environment.UserName
            Dim ewhSec As New EventWaitHandleSecurity()

            Dim rule As New EventWaitHandleAccessRule(user, _
                EventWaitHandleRights.Synchronize Or _
                EventWaitHandleRights.Modify, _
                AccessControlType.Deny)
            ewhSec.AddAccessRule(rule)

            rule = New EventWaitHandleAccessRule(user, _
                EventWaitHandleRights.ReadPermissions Or _
                EventWaitHandleRights.ChangePermissions, _
                AccessControlType.Allow)
            ewhSec.AddAccessRule(rule)

            ' Create an EventWaitHandle object that represents
            ' the system event named by the constant 'ewhName', 
            ' initially signaled, with automatic reset, and with
            ' the specified security access. The Boolean value that 
            ' indicates creation of the underlying system object
            ' is placed in wasCreated.
            '
            ewh = New EventWaitHandle(True, _
                EventResetMode.AutoReset, ewhName, _
                wasCreated, ewhSec)

            ' If the named system event was created, it can be
            ' used by the current instance of this program, even 
            ' though the current user is denied access. The current
            ' program owns the event. Otherwise, exit the program.
            ' 
            If wasCreated Then
                Console.WriteLine("Created the named event.")
            Else
                Console.WriteLine("Unable to create the event.")
                Return
            End If

        ElseIf unauthorized Then

            ' Open the event to read and change the access control
            ' security. The access control security defined above
            ' allows the current user to do this.
            '
            Try
                ewh = EventWaitHandle.OpenExisting(ewhName, _
                    EventWaitHandleRights.ReadPermissions Or _
                    EventWaitHandleRights.ChangePermissions)

                ' Get the current ACL. This requires 
                ' EventWaitHandleRights.ReadPermissions.
                Dim ewhSec As EventWaitHandleSecurity = _
                    ewh.GetAccessControl()
                
                Dim user As String = Environment.UserDomainName _ 
                    & "\" & Environment.UserName

                ' First, the rule that denied the current user 
                ' the right to enter and release the event must
                ' be removed.
                Dim rule As New EventWaitHandleAccessRule(user, _
                    EventWaitHandleRights.Synchronize Or _
                    EventWaitHandleRights.Modify, _
                    AccessControlType.Deny)
                ewhSec.RemoveAccessRule(rule)

                ' Now grant the user the correct rights.
                ' 
                rule = New EventWaitHandleAccessRule(user, _
                    EventWaitHandleRights.Synchronize Or _
                    EventWaitHandleRights.Modify, _
                    AccessControlType.Allow)
                ewhSec.AddAccessRule(rule)

                ' Update the ACL. This requires
                ' EventWaitHandleRights.ChangePermissions.
                ewh.SetAccessControl(ewhSec)

                Console.WriteLine("Updated event security.")

                ' Open the event with (EventWaitHandleRights.Synchronize 
                ' Or EventWaitHandleRights.Modify), the rights required
                ' to wait on and signal the event.
                '
                ewh = EventWaitHandle.OpenExisting(ewhName)

            Catch ex As UnauthorizedAccessException
                Console.WriteLine("Unable to change permissions: {0}", _
                    ex.Message)
                Return
            End Try

        End If

        ' Wait on the event, and hold it until the program
        ' exits.
        '
        Try
            Console.WriteLine("Wait on the event.")
            ewh.WaitOne()
            Console.WriteLine("Event was signaled.")
            Console.WriteLine("Press the Enter key to signal the event and exit.")
            Console.ReadLine()
        Catch ex As UnauthorizedAccessException
            Console.WriteLine("Unauthorized access: {0}", _
                ex.Message)
        Finally
            ewh.Set()
        End Try
    End Sub 
End Class

설명

이 생성자를 사용하여 만들 때 명명된 시스템 이벤트에 액세스 제어 보안을 적용하여 다른 코드가 이벤트를 제어하지 못하도록 합니다.

이 생성자는 시스템 이벤트를 나타내는 개체를 초기화 EventWaitHandle 합니다. 동일한 시스템 이벤트를 나타내는 여러 EventWaitHandle 개체를 만들 수 있습니다.

시스템 이벤트가 없는 경우 지정된 액세스 제어 보안을 사용하여 생성됩니다. 이벤트가 있는 경우 지정된 액세스 제어 보안이 무시됩니다.

참고

호출자는 현재 사용자에게 일부 액세스 권한을 거부하거나 부여하지 않더라도 eventSecurity 새로 만든 EventWaitHandle 개체를 완전히 제어할 수 있습니다. 그러나 현재 사용자가 생성자 또는 OpenExisting 메서드를 사용하여 동일한 명명된 이벤트를 나타내는 다른 EventWaitHandle 개체를 얻으려고 하면 Windows 액세스 제어 보안이 적용됩니다.

name 접두사를 추가 Global\ 하거나 Local\ 네임스페이스를 지정할 수 있습니다. 네임스페이 Global 스를 지정하면 동기화 개체를 시스템의 모든 프로세스와 공유할 수 있습니다. Local 네임스페이스를 지정하면 네임스페이스가 지정되지 않은 경우에도 기본값이 되며, 동기화 개체를 동일한 세션의 프로세스와 공유할 수 있습니다. Windows에서 세션은 로그인 세션이며 서비스는 일반적으로 다른 비대화형 세션에서 실행됩니다. Unix와 유사한 운영 체제에서 각 셸에는 자체 세션이 있습니다. 세션-로컬 동기화 개체는 모두 동일한 세션에서 실행되는 부모/자식 관계와 프로세스 간의 동기화에 적합할 수 있습니다. Windows의 동기화 개체 이름에 대한 자세한 내용은 개체 이름을 참조하세요.

name 제공되고 요청된 형식의 동기화 개체가 네임스페이스에 이미 있는 경우 기존 동기화 개체가 열립니다. 다른 형식의 동기화 개체가 네임스페이스에 이미 있는 경우 이 WaitHandleCannotBeOpenedException throw됩니다. 그렇지 않으면 새 동기화 개체가 만들어집니다.

매개 변수에 대해 name 지정된 이름의 시스템 이벤트가 이미 있는 initialState 경우 매개 변수는 무시됩니다. 이 생성자를 호출한 후 매개 변수(ByRefVisual Basic의 매개 변수) createdNewref 지정된 변수의 값을 사용하여 명명된 시스템 이벤트가 이미 있는지 또는 만들어졌는지 확인합니다.

이벤트의 초기 상태가 서명되지 않은 경우 이벤트를 대기하는 스레드가 차단됩니다. 초기 상태가 신호를 받고 플래그가 ManualResetmode대해 지정된 경우 이벤트를 기다리는 스레드는 차단되지 않습니다. 초기 상태가 신호이고 modeAutoReset면 이벤트를 대기하는 첫 번째 스레드가 즉시 해제되고 그 후에 이벤트가 다시 설정되고 후속 스레드가 차단됩니다.

주의

기본적으로 명명된 이벤트는 이벤트를 만든 사용자로 제한되지 않습니다. 다른 사용자는 이벤트를 설정하거나 부적절하게 다시 설정하여 이벤트를 방해하는 등 이벤트를 열고 사용할 수 있습니다. 특정 사용자에 대한 액세스를 제한하려면 명명된 EventWaitHandleSecurity 이벤트를 만들 때 을 전달할 수 있습니다. 신뢰할 수 없는 사용자가 코드를 실행 중일 수 있는 시스템에 액세스 제한 없이 명명된 이벤트를 사용하지 마세요.

추가 정보

적용 대상