.NET Ne peut pas effectuer cette opération pendant répartiteur de traitement est suspendu

J'ai la méthode suivante dans une classe de base qui met en œuvre le Système.ComponentModel.INotifyPropertyChanged:

protected virtual void RaisePropertyChangedEventSynchronous(string propertyName)
{                    
    try
    {
        if (PropertyChanged != null)
        {
            Delegate[] delegates = this.PropertyChanged.GetInvocationList();
            foreach (PropertyChangedEventHandler handler in delegates)
            {                      
                try
                {
                    DispatcherObject dispatcherInvoker = handler.Target 
                        as DispatcherObject;
                    if (dispatcherInvoker != null)
                    {                                
                        dispatcherInvoker.Dispatcher.Invoke(DispatcherPriority.Normal, 
                            new Action(delegate
                        {
                            handler(this, new PropertyChangedEventArgs(propertyName));
                        }));
                    }
                    else
                    {
                        handler(this, new PropertyChangedEventArgs(propertyName));
                    }
                }
                catch (Exception ex)
                {                     
                    ExceptionPolicy.HandleException(ex, 
                        ExceptionHandlingPolicyNames.LogPolicy);
                }
            }
        }
    }
    catch (Exception ex)
    {
         ExceptionPolicy.HandleException(ex, ExceptionHandlingPolicyNames.LogPolicy);
    }
}

À l'occasion, je voudrais obtenir de l'exception suivante connecté pour fichier:

Type : System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Impossible d'effectuer cette opération pendant le répartiteur de la suspension du traitement de la.
Source : WindowsBase
Lien d'aide :
Données : Système D'.Les Collections.ListDictionaryInternal
TargetSite : Void PushFrame(Système D'.De Windows.Le filetage.DispatcherFrame)
Trace de la pile : au Système.De Windows.Le filetage.Répartiteur.PushFrame(DispatcherFrame image)
au Système.De Windows.Le filetage.DispatcherOperation.Attendre(plage de Temps (timeout)
au Système.De Windows.Le filetage.Répartiteur.InvokeImpl(DispatcherPriority de priorité, le Délai de timeout, Délégué de la méthode, l'Objet args, Boolean isSingleParameter)
au Système.De Windows.Le filetage.Répartiteur.Invoke(DispatcherPriority priorité, le Délégué de la méthode)
au OCC600.L'Infrastructure.De dictionnaire.BusinessEntities.Observables.RaisePropertyChangedEventSynchronous(String propertyName)

Si j'utilise Répartiteur.BeginInvoke de mise à jour de l'INTERFACE utilisateur, je ne comprends pas ces exceptions. Mais j'ai trouvé que le fait d'effectuer des mises à jour à l'aide de BeginInvoke n'est pas fiable car parfois, ces modifications ne sont pas répercutées sur l'interface utilisateur.

Comment puis-je résoudre ce?

OriginalL'auteur Klaus Nji | 2010-12-09