Exemple #1
0
        public virtual void Dispose(bool disposing)
        {
            var disposable = Inner as IDisposable;

            disposable?.Dispose();
            Inner = null;
            if (disposing)
            {
                // no pooling from finalizers, just don't do that
                if (Pool == null)
                {
                    Pool = new BoundedConcurrentBag <TImpl>(Environment.ProcessorCount * 2);
                }
                if (!Pool.TryAdd(this as TImpl))
                {
                    // not added to the pool, let it die
                    GC.SuppressFinalize(this);
                }
            }
        }