InvalidOperationException: dispatcher processing has been suspended, but messages are still being processed
<p>We are having multiple issues with this exception but I cannot find technical documentation about the real cause of the issue, all the possible sources for this error and what should we avoid to avoid having the exception.</p>

<p>I have read the following:</p>

<blockquote>
  <p>The dispatcher processing is suspended to avoid reentrancy problems
  when updating the visual tree.</p>
</blockquote>

<p>But I'm unsure about what means 'updating the visual tree' and what causes a message to be sent to the Dispatcher and reproduces the issue.</p>

<p>The following sample code reproduces the issue:</p>

<p>XAML</p>

<pre><code>&lt;Window x:Class="SuspendedPOF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" 
        Height="350" 
        Width="525"&gt;
    &lt;StackPanel&gt;
        &lt;Button Content="1" x:Name="Button1"  IsVisibleChanged="Button1_OnIsVisibleChanged" /&gt;
    &lt;/StackPanel&gt;
&lt;/Window&gt;
</code></pre>

<p>C# Code</p>

<pre><code>using System.Windows;

namespace SuspendedPOF
{
    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button1_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            MessageBox.Show("Hello");
        }
    }
}
</code></pre>

<p>The MessageBox call is not the only one that fires this exception, things like Focus sometimes are problematic as well.</p>

<p>Any help would be great.</p>