} // ConnectionCount private void OnConnected(Socket s) { if (ConnectionCount() >= 10) { s.Close(); } else { for (int intIndex = 0; intIndex <= 9; intIndex++) { if (objPOP3Sessions[intIndex] == null) { objPOP3Sessions[intIndex] = new POP3Session(s); objPOP3Sessions[intIndex].OnDisconnect += OnDisconnected; break; } } } objTCPPort.AcceptAsync().ContinueWith(t => { if (!t.IsFaulted) { OnConnected(t.Result); } }).Wait(0); } // OnConnected
} // OnConnected private void OnDisconnected(POP3Session s) { for (int intIndex = 0; intIndex <= 9; intIndex++) { if (objPOP3Sessions[intIndex] == s) { objPOP3Sessions[intIndex] = null; } } } // OnDisconnected