public ServiceInstanceContainer GetInstanceContainer() { lock (_poolLock) { if (Pool.Count > 0) { return(Pool.Pop()); } var serviceInstance = _serviceCreator(); var container = new ServiceInstanceContainer(this, serviceInstance); return(container); } }
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(); } } } }
public ServiceInstanceContainer GetInstanceContainer() { lock (_poolLock) { if (Pool.Count > 0) return Pool.Pop(); var serviceInstance = _serviceCreator(); var container = new ServiceInstanceContainer(this, serviceInstance); return container; } }