Exemplo n.º 1
0
        public WeakEventHandler(TInstance target, Action <TInstance, object, TEventArgs> handler, Action <THandler> addHandler, Action <THandler> remove)
        {
            _innerDelegateProxy = new WeakEventHandlerProxy <THandler, TEventArgs>(Invoke);

            _targetReference = new WeakReference <TInstance>(target);
            _handler         = handler;
            _removeHandler   = remove;

            addHandler(_innerDelegateProxy.Handler);
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _removeHandler(_innerDelegateProxy.Handler);
            _removeHandler      = null;
            _targetReference    = null;
            _innerDelegateProxy = null;
            _handler            = null;

            _isDisposed = true;
        }