示例#1
0
        /// <summary>
        /// Notifies all registered event handlers of the occurance of an event!
        /// </summary>
        /// <param name="e">The event that occured</param>
        /// <param name="sender">The sender of this event</param>
        /// <param name="eArgs">The event arguments</param>
        /// <remarks>Overwrite the EventArgs class to set own arguments</remarks>
        public void Notify(DOLEvent e, object sender, EventArgs eArgs)
        {
            WeakMulticastDelegate eventDelegate = null;

            if (_lock.TryEnterReadLock(LOCK_TIMEOUT))
            {
                try
                {
                    if (!_events.TryGetValue(e, out eventDelegate))
                    {
                        return;
                    }
                }
                finally
                {
                    _lock.ExitReadLock();
                }
            }

            eventDelegate.InvokeSafe(new[] { e, sender, eArgs });
        }