Пример #1
0
        protected virtual void OnDisposed(OnDisposedEventArgs e)
        {
            OnDisposedEventHandler[] handlers = null;
            Monitor.Enter(this);
            try
            {
                if (_handlers != null)
                {
                    handlers = new OnDisposedEventHandler[_handlers.Count];
                    _handlers.CopyTo(handlers, 0);
                    _handlers.Clear();
                }
            }
            finally
            {
                Monitor.Exit(this);
            }

            if (handlers != null)
            {
                foreach (OnDisposedEventHandler handler in handlers)
                {
                    if (handler != null)
                    {
                        AsyncHelper.FireAndForget(handler, this, e);
                    }
                }
            }
        }
Пример #2
0
        protected virtual void OnDisposed(OnDisposedEventArgs e)
        {
            OnDisposedEventHandler[] handlers = null;
            Monitor.Enter(this);
            try
            {
                if (_handlers != null)
                {
                    handlers = new OnDisposedEventHandler[_handlers.Count];
                    _handlers.CopyTo(handlers, 0);
                    _handlers.Clear();
                }
            }
            finally
            {
                Monitor.Exit(this);
            }

            if (handlers != null)
            {
                foreach (OnDisposedEventHandler handler in handlers)
                {
                    if (handler != null)
                        AsyncHelper.FireAndForget(handler, this, e);
                }
            }
        }