Esempio n. 1
0
 public ObjectPool(int maxObjects,
                   CreateObjectDelegate creator,
                   AllocObjectDelegate allocator,
                   DisposeObjectDelegate disposer)
 {
     if (creator == null)
     {
         throw new ArgumentNullException("CreateObjectDelegate creator");
     }
     _creator   = creator;
     _allocator = allocator;
     _disposer  = disposer;
     _pool      = new PoolEntry[maxObjects];
 }
 public void DisposeDisposalBin(DisposeObjectDelegate callBack)
 {
     if (this.disposalBin == null)
     {
         return;
     }
     foreach (IDisposable toBeDisposed in this.disposalBin)
     {
         if (callBack != null)
         {
             callBack(toBeDisposed);
         }
         else
         {
             toBeDisposed.Dispose();
         }
     }
     this.disposalBin.Clear();
 }