Exemplo n.º 1
0
        public SocketAsyncEventArgsPool(int poolSize, int maxSize, int bufferSize)
        {
            maxPoolSize = maxSize;
            argsPool = new BlockingCollection<SocketAsyncEventArgs>(new ConcurrentQueue<SocketAsyncEventArgs>());
            bufferManager = new BufferManager(bufferSize);

            Init(poolSize);
        }
Exemplo n.º 2
0
        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;
        }