public SocketAsyncEventArgsPool(int poolSize, int maxSize, int bufferSize) { _maxPoolSize = maxSize; _argsPool = new BlockingCollection<SocketAsyncEventArgs>(new ConcurrentQueue<SocketAsyncEventArgs>()); _bufferManager = new BufferManager(bufferSize); Init(poolSize); }
protected virtual void Dispose(bool disposing) { if (disposing) { _argsPool.CompleteAdding(); while (_argsPool.Count > 0) { SocketAsyncEventArgs arg = _argsPool.Take(); _bufferManager.ClearBuffer(arg); arg.Dispose(); } } _bufferManager = null; }