public void ReturnItem(T returnItem) { PooledItem <T> item = poolList.Find(i => i.pooledItem.Equals(returnItem)); if (item != null) { item.isInUse = false; } }
public T GetItem() { PooledItem <T> item = new PooledItem <T>(); if (poolList.Count > 0) { item = poolList.Find(i => i.isInUse == false); if (item != null) { item.isInUse = true; return(item.pooledItem); } } item.pooledItem = CreateNewItem(); item.isInUse = true; poolList.Add(item); return(item.pooledItem); }