private void StartServer() { stopped = false; listener.Start(); if (OnStarted != null) { OnStarted(this); } Socket client = null; do { try { client = listener.AcceptSocket(); lock (synclock) { clientsList.Add(client); } ClientHandlerDelegate del = new ClientHandlerDelegate(ClientHandler); del.BeginInvoke(client, new AsyncCallback(ClientHandlerEnd), del); } catch (Exception e) { // Do nothing.... } } while (!stopped); }
private void ClientHandlerEnd(IAsyncResult result) { ClientHandlerDelegate asyncDel = result.AsyncState as ClientHandlerDelegate; asyncDel.EndInvoke(result); }