title: Exiting an application that is blocked waiting for an incoming pipe stream
body: <p>I have an application that runs a NamedPipeServerStream in a thread and waits for connections on it like so:</p>
  
  <pre><code>NamedPipeServerStream pipeServerTemp = new NamedPipeServerStream(PIP_NAME, PipeDirection.InOut, 254);
  pipeServerTemp.WaitForConnection();
  </code></pre>
  
  <p>The application is always waiting for new connections, but when I try to kill the app the process hangs on the call to WaitForConnection.</p>
  
  <p>I've tried aborting the thread in question but it doesn't kill the application.</p>
  
  <p>How can I tell the NamedPipeServerStream to stop listening for connections?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I can see that NamedPipeServerStream has a method called <code>EndWaitForConnection</code> but it needs a reference to an <code>IAsynchResult</code>, where would I get that object?</p>