title: App freezes after Dispatcher.Invoke
body: <p>I have this application that freezes when calling the dispatcher.invoke for any control.</p>
  
  <p>When i Call the Dispatcher in radiobutton, Grid, Image..etc the App freezes but without giving errors. any help please !!! thank you</p>
  
  <p>I call the thread Method RunClient</p>
  
  <pre><code>private void RunClient()
      {
  
          TcpClient client;
  
          // instantiate TcpClient for sending data to server
          try
          {
              // Step 1: create TcpClient and connect to server
  
              client = new TcpClient();
              client.Connect(ip, 5001);
  
              // Step 2: get NetworkStream associated with TcpClient
              output = client.GetStream();
  
              // create objects for writing and reading across stream
              writer = new BinaryWriter(output);
              reader = new BinaryReader(output);
  
              string theReply = "";
  
              do
              {
                  try
                  {
                      // read the string sent to the server
                      theReply = reader.ReadString();
  
                      int i = 0;
  
                      foreach (var x in theReply.Split('#'))
                      {
                          ReadString[i] = x;
                          i++;
                      }
  
                      CheckConnection(ReadString[0]);
  
  
  
                  }
                  catch (Exception)
                  {
                      //do nothing
                  }
  
              } while (ReadString[6].Equals(" ") &amp;&amp;
                     connection.Connected);
  
              updatelabel = () =&gt; GameResult(ReadString[6]);
              Dispatcher.Invoke(new Action(updatelabel));
  
              if (!connection.Connected)
              {
                  MessageBox.Show("The connection was lost. The game will be closed automatically.");
                  writer.Close();
                  reader.Close();
                  output.Close();
                  connection.Close();
                  this.Close();
              }
  
          }
          // handle exception if error in establishing connection
          catch (Exception error)
          {
              MessageBox.Show("Check Internet Connectivity. Couldn't connect!");
          }
  
  
      }
  </code></pre>
  
  <p>when the code enters the method ( check connection ) and calls the dispatcher the app freezes.</p>
  
  <pre><code>     void CheckConnection(string ii)
      {
          try
          {
              if (ii.Equals("Connected"))
              {
                  MessageBox.Show("A Connection was established");
  
  
  
  
                  int x = Convert.ToInt32(ReadString[1]);
  
                  if (x == 1)
                  {
  
                      updatelabel = () =&gt; char1RadioButton2.IsEnabled = false;
                      char1RadioButton2.Dispatcher.Invoke(new Action(updatelabel));
                  }
  
                  else
                  {
                      updatelabel = () =&gt; char5RadioButton2.IsEnabled = false;
                      char5RadioButton2.Dispatcher.Invoke(new Action(updatelabel));
                  }
  
  
                  updatelabel = () =&gt; CreatingGameGrid.Visibility = System.Windows.Visibility.Visible;
                  CreatingGameGrid.Dispatcher.Invoke(new Action(updatelabel));
  
  
  
                  updatelabel = () =&gt; JoinGameGrid.Visibility =        System.Windows.Visibility.Visible;
                  JoinGameGrid.Dispatcher.Invoke(new Action(updatelabel));
  
              }
              else
              {
                  MessageBox.Show("No Such Game found");
                  this.Close();
              }
          }
          catch (Exception x)
          {
              MessageBox.Show(x.ToString());
          }
      }
  </code></pre>