title: Invalid cross-thread access despite using the dispatcher
body: <p>I have read up about this problem I am having and I cannot seem to find a solution for it. Some people have recommended to use the dispatcher to push the code execution onto the UI Thread. However this does not solve my issue. I am calling this code out of an Asyc method which is before hand called by a Guide object to display a notification. The code which controls the UI stuff is as follows:</p>
  
  <pre><code>public bool isDisabled
  {
      set
      {
          if (value)
          {
              Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
                  {
                      color = new SolidColorBrush(Colors.Gray);
                  });
              enabled = false;
          }
          else
          {
              Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
                  {
                      color = origionalColor;
                  });
              enabled = true;
          }
      }
  }
  </code></pre>
  
  <p>and it is being called from</p>
  
  <pre><code>    private void nameInputFinished(IAsyncResult ar)
      {
          int? result = Guide.EndShowMessageBox(ar);
  
          if (result == 0)
          {
               [...]
  
               JourneyPanels.getPanel(JourneyPanelTypes.integration).isDisabled = false;
          }
      }
  </code></pre>
  
  <p>Not sure why I am getting the corss-thread exception but I am pretty sure it has something to do with the async method nesting.</p>
  
  <p>Any help is greatly appreciated!</p>
  
  <p>EDIT: Full Exception Stack</p>
  
  <pre><code>  {System.UnauthorizedAccessException: Invalid cross-thread access.
    at MS.Internal.XcpImports.CheckThread()
    at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, Boolean b)
    at System.Windows.DependencyObject.SetValue(DependencyProperty property, Boolean b)
    at System.Windows.Controls.TextBox.set_IsReadOnly(Boolean value)
    at PocketRitual.Journey.nameInputFinished(IAsyncResult ar)
    at Microsoft.Xna.Framework.GamerServices.ActionDialogHelper.Complete()
    at Microsoft.Xna.Framework.GamerServices.ActionDialogHelper.GetMessageBoxResult(Object state)
    at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    at System.Threading.ThreadPoolWorkQueue.Dispatch()
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()}
  </code></pre>