private void Register(SimpleSocketRequest <T, R> request) { _agenda.Add(_handler.Execute(request)); if (_agenda.Count > 100) { foreach (var task in _agenda.ToArray()) { if (task.IsCompleted) { _agenda.Remove(task); } } } }
void _accept_Completed(object sender, SocketAsyncEventArgs e) { var socket = e.AcceptSocket; if (Cancel.IsCancellationRequested) { socket.Close(); ShutDown(); return; } var request = new SimpleSocketRequest <T, R>(socket); Register(request); Accept(); }