Ejemplo n.º 1
0
        // event handler for PropertyChanged event
        private void OnStaticPropertyChanged(TypeRecord typeRecord, PropertyChangedEventArgs args)
        {
            ListenerList list;

            // get the list of listeners
            using (ReadLock)
            {
                list = typeRecord.GetListenerList(args.PropertyName);

                // mark the list "in use", even outside the read lock,
                // so that any writers will know not to modify it (they'll
                // modify a clone intead).
                list.BeginUse();
            }

            // deliver the event, being sure to undo the effect of BeginUse().
            try
            {
                DeliverEventToList(null, args, list);
            }
            finally
            {
                list.EndUse();
            }

            // if we calculated an AllListeners list, we should now try to store
            // it in the dictionary so it can be used in the future.  This must be
            // done under a WriteLock - which is why we didn't do it immediately.
            if (list == typeRecord.ProposedAllListenersList)
            {
                using (WriteLock)
                {
                    typeRecord.StoreAllListenersList((ListenerList <PropertyChangedEventArgs>)list);
                }
            }
        }
        // event handler for PropertyChanged event
        private void OnStaticPropertyChanged(TypeRecord typeRecord, PropertyChangedEventArgs args)
        {
            ListenerList list;

            // get the list of listeners
            using (ReadLock)
            {
                list = typeRecord.GetListenerList(args.PropertyName);

                // mark the list "in use", even outside the read lock,
                // so that any writers will know not to modify it (they'll
                // modify a clone intead).
                list.BeginUse();
            }

            // deliver the event, being sure to undo the effect of BeginUse().
            try
            {
                DeliverEventToList(null, args, list);
            }
            finally
            {
                list.EndUse();
            }

            // if we calculated an AllListeners list, we should now try to store
            // it in the dictionary so it can be used in the future.  This must be
            // done under a WriteLock - which is why we didn't do it immediately.
            if (list == typeRecord.ProposedAllListenersList)
            {
                using (WriteLock)
                {
                    typeRecord.StoreAllListenersList((ListenerList<PropertyChangedEventArgs>)list);
                }
            }
        }