Ejemplo n.º 1
0
        public ServiceInstanceContainer GetInstanceContainer()
        {
            lock (_poolLock)
            {
                if (Pool.Count > 0)
                {
                    return(Pool.Pop());
                }

                var serviceInstance = _serviceCreator();
                var container       = new ServiceInstanceContainer(this, serviceInstance);
                return(container);
            }
        }
Ejemplo n.º 2
0
 public void ReleaseInstanceContainer(ServiceInstanceContainer instance)
 {
     lock (_poolLock)
     {
         if (Pool.Count <= Size)
         {
             Pool.Push(instance);
         }
         else
         {
             var o = instance.ServiceObject as IDisposable;
             if (o != null)
             {
                 o.Dispose();
             }
         }
     }
 }
Ejemplo n.º 3
0
        public ServiceInstanceContainer GetInstanceContainer()
        {
            lock (_poolLock)
            {
                if (Pool.Count > 0)
                    return Pool.Pop();

                var serviceInstance = _serviceCreator();
                var container = new ServiceInstanceContainer(this, serviceInstance);
                return container;
            }
        }
Ejemplo n.º 4
0
 public void ReleaseInstanceContainer(ServiceInstanceContainer instance)
 {
     lock (_poolLock)
     {
         if (Pool.Count <= Size)
         {
             Pool.Push(instance);
         }
         else
         {
             var o = instance.ServiceObject as IDisposable;
             if (o != null)
             {
                 o.Dispose();
             }
         }
     }
 }