public WeakCollection(IEqualityComparer <T> comparer, bool autoRemoveDeadItems) { _comparer = comparer ?? EqualityComparer <T> .Default; _wrapped = new SafeCollection <TNeedle>(); if (autoRemoveDeadItems) { RegisterForAutoRemoveDeadItemsExtracted(); } else { GC.SuppressFinalize(this); } }
public StrongDelegateCollection(bool freeReentry) { IEqualityComparer <Delegate> comparer = EqualityComparer <Delegate> .Default; _wrapped = new SafeCollection <Delegate>(comparer); if (freeReentry) { _invoke = InvokeExtracted; _invokeWithException = InvokeExtracted; } else { var guard = new ReentryGuard(); _invoke = input => guard.Execute(() => InvokeExtracted(input)); _invokeWithException = (onException, input) => guard.Execute(() => InvokeExtracted(onException, input)); } }