/// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <filterpriority>2</filterpriority>
        public void Dispose()
        {
            if (_pool == null)
            {
                return;
            }

            _pool.Push(Buffer);
            _pool = null;
        }
Пример #2
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="T:System.IO.MemoryStream"/> class and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (!_returnedBuffer)
            {
                if (_pool != null)
                {
                    _pool.Push(GetBuffer());
                }
                _returnedBuffer = true;
            }

            base.Dispose(disposing);
        }
Пример #3
0
 protected override void Dispose(bool disposing)
 {
     _bufferPool.Push(_buffer);
     _disposed = true;
     base.Dispose(disposing);
 }