title: Is correct this pattern for an asynchronous TCP listener?
body: <p>I was wondering if I'm doing right in an application I'm building. The app has to receive incoming TCP connections, and use a thread per call, so the server can answer multiple calls in parallel.</p>
  
  <p>What I'm doing is call <code>BeginAcceptTcpClient</code> again as soon I got an accepted client. I guess that when the <code>ConnectionAccepted</code> method is hit, it's actually in a separate thread.</p>
  
  <pre><code>public class ServerExample:IDisposable
  {
      TcpListener _listener;
      public ServerExample()
      {
          _listener = new TcpListener(IPAddress.Any, 10034);
          _listener.Start();
          _listener.BeginAcceptTcpClient(ConnectionAccepted,null);
      }
  
      private void ConnectionAccepted(IAsyncResult ia)
      {
          _listener.BeginAcceptTcpClient(ConnectionAccepted, null);
          try
          {
              TcpClient client = _listener.EndAcceptTcpClient(ia);
  
              // work with your client
              // when this method ends, the poolthread is returned
              // to the pool.
          }
          catch (Exception ex)
          {
              // handle or rethrow the exception
          }
      }
  
      public void Dispose()
      {
          _listener.Stop();
      }
  }
  </code></pre>
  
  <p>Am I doing right?</p>
  
  <p>Cheers.</p>