Exemplo 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);
            }
        }
Exemplo 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();
             }
         }
     }
 }
Exemplo 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;
            }
        }
Exemplo 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();
             }
         }
     }
 }