public virtual object Request(CreationContext context, Func <CreationContext, Burden> creationCallback) { Burden burden; using (rwlock.ForWriting()) { if (!initialized) { Intitialize(creationCallback, context); } if (available.Count != 0) { burden = available.Pop(); context.AttachExistingBurden(burden); } else { burden = creationCallback.Invoke(context); } try { inUse.Add(burden.Instance, burden); } catch (NullReferenceException) { throw new PoolException("creationCallback didn't return a valid burden"); } catch (ArgumentNullException) { throw new PoolException("burden returned by creationCallback does not have root instance associated with it (its Instance property is null)."); } } return(burden.Instance); }