private void BeginAcceptTcpClientCallback(IAsyncResult ar) { try { var client = listener.EndAcceptTcpClient(ar); Interlocked.Increment(ref concurrentConnection); // accept additional connections listener.BeginAcceptTcpClient(BeginAcceptTcpClientCallback, null); var clientConnection = new ClientConnection(client, client.GetStream(), ()=>Interlocked.Decrement(ref concurrentConnection)); clientConnection.ProcessNextCommand(); } catch (ObjectDisposedException) { } }
private void BeginAcceptTcpClientCallback(IAsyncResult ar) { try { var client = listener.EndAcceptTcpClient(ar); Interlocked.Increment(ref concurrentConnection); // accept additional connections listener.BeginAcceptTcpClient(BeginAcceptTcpClientCallback, null); var clientConnection = new ClientConnection(client, client.GetStream(), () => Interlocked.Decrement(ref concurrentConnection)); clientConnection.ProcessNextCommand(); } catch (ObjectDisposedException) { } }