public override void ReturnObject(T obj) { PooledObject <T> p = allObjects[obj] as PooledObject <T>; if (p == null) { throw new IllegalStateException("Returned object not currently part of this pool"); } if (TestOnReturn) { if (!factory.ValidateObject(obj)) { try { Destroy(p); } catch { } return; } } try { factory.SuspendObject(obj); } catch { try { Destroy(p); } catch { } return; } if (!p.Deallocate()) { throw new IllegalStateException("Object has already been retured to this pool"); } int maxIdle = MaxIdle; if (IsClosed || maxIdle > -1 && maxIdle <= idleObjects.Size()) { try { Destroy(p); } catch { } } else { if (Lifo) { idleObjects.AddFirst(p); } else { idleObjects.AddLast(p); } } }