/// <inheritdoc /> protected override void OnDispose(bool disposing) { if (disposing) { _receiveEventArgsPool?.Dispose(); _sendEventArgsPool?.Dispose(); } }
public void PopPush_Disposed_Exception() { var pool = new SocketAsyncEventArgsPool(64); // Populate the pool. for (int i = 0; i < 64; i++) { pool.Push(new SocketAsyncEventArgs()); } // Remove a couple of the args. for (int i = 0; i < 32; i++) { pool.Pop(); } pool.Dispose(); Assert.Throws <ObjectDisposedException>(() => pool.Push(new SocketAsyncEventArgs())); Assert.Throws <ObjectDisposedException>(() => pool.Pop()); }