title: Named Events to notify Windows Application
body: <p>I have a requirement to send signal from Windows Service to a Windows console/Forms application using Named Events like Auto Reset Events and Manual reset events. I understand AutoResetEvents and ManualResetEvents are mainly used for thread synchronization, but now I have a requirement to use named events to signal a Windows Forms application. I EventWaitHandler and wrote code which can do this, by my windows service is crashing at the SetSignalToClient method call</p>
  
  <p>In Event Viewer I found the exception as:
  Exception Info: System.Threading.WaitHandleCannotBeOpenedException</p>
  
  <p>Windows Service Code:</p>
  
  <pre><code>public void SetSignalToClient()
  {
  
   System.Threading.EventWaitHandle wh =  EventWaitHandle.OpenExisting("MyEventName", EventWaitHandleRights.Modify);
  
  wh.Set();
  }
  </code></pre>
  
  <p>Windows Forms Application:</p>
  
  <pre><code>public void ReceiveSignalFromClient()
  {
    textBox1.Text = "Successful";
    while (true)
     {
      EventWaitHandle wh = new EventWaitHandle(false,  EventResetMode.AutoReset, "MyEventName");
      wh.WaitOne(); 
      textBox1.Text = "Failed"; 
     }
  
  }
  </code></pre>
  
  <p>Thanks in advance...</p>