Esempio n. 1
0
        /// <summary>
        /// Proxy for the CollectionChanged event that hides issues with re-entrancy and no listeners.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event arguments.</param>
        private void _NotifyCollectionChanged(object sender, ContactCollectionChangedEventArgs e)
        {
            Assert.IsTrue(CheckAccess());

            // Only process these if we haven't already started disposing this...
            if (!_disposed)
            {
                // By assigning to a temporary we avoid race conditions with the event losing listeners
                // after the null check, and ensure that we don't end up in any kind of weird cycle due
                // to re-entrancy.
                EventHandler<ContactCollectionChangedEventArgs> handler = _CollectionChangedInternal;
                if (null != handler)
                {
                    handler(sender, e);
                }
            }
        }
Esempio n. 2
0
            private void _ListenForMeContactChanges(object sender, ContactCollectionChangedEventArgs e)
            {
                // If there is no MeContact in the registry then we don't care about
                // changes to any contact - none of them is going to be Me.
                if (null != _meContactId)
                {
                    bool changed = false;

                    Contact contact;
                    string realMeId = GetMeContactId();
                    if (_manager.TryGetContact(realMeId, out contact))
                    {
                        if (e.NewId == contact.Id)
                        {
                            changed = true;
                        }
                    }
                    else
                    {
                        changed = true;
                    }

                    if (changed)
                    {
                        PropertyChangedEventHandler handler = _PropertyChangedInternal;
                        if (null != handler)
                        {
                            handler(this, new PropertyChangedEventArgs("MeContact"));
                        }
                    }
                }
            }