private void AddLockFree(TcpClientData clientData) { if (this._count == this._clients.Length) { Array.Resize(ref this._clients, 2 * _count); } this._clients[this._count++] = clientData; // Raise add event this.OnClientAdded?.Invoke(this, new TcpClientsEventArgs(clientData.ReceiveBuffer)); }
public void Add(TcpClientData clientData) { if (_lockCount > 0) { lock (_lockObj) { if (this._pendingAddCount == this._pendingAddClients.Length) { Array.Resize(ref this._pendingAddClients, 2 * this._pendingAddCount); } this._pendingAddClients[this._pendingAddCount++] = clientData; return; } } AddLockFree(clientData); }