Exemplo n.º 1
0
            public override Delegate RemoveHandler(object callableObject, IEqualityComparer <object> comparer)
            {
                List <KeyValuePair <WeakReference, WeakReference> > copyOfHandlers = _handlers.GetCopyForRead();

                for (int i = copyOfHandlers.Count - 1; i >= 0; i--)
                {
                    object key   = copyOfHandlers[i].Key.Target;
                    object value = copyOfHandlers[i].Value.Target;

                    if (key != null && value != null && comparer.Equals(key, callableObject))
                    {
                        Delegate handler = (Delegate)value;
                        _handlers.RemoveAt(i);
                        return(handler);
                    }
                }

                return(null);
            }