title: c# - Form components not updating when using sockets
body: <p>Good day all</p>
  
  <p>This is a piece of code which is part of a small lan chat (expermentation) program, however when sending messages to this, the server, it is recieved (as per debugging I can see the results) but the gui fails to update (gui meaning richedit and label)</p>
  
  <p>When I click send, the receiveText(string IP) is called, which executes and awaits for a connection, when it recieves a connetion, it handles as it should but,</p>
  
  <p><strong>Problem :</strong> </p>
  
  <p><em>Only after this method (and related) have been executed, the gui updates</em>, so when this method finishes, and its calling method finishes (button_click) too, only then while the program is waiting for input, they richedit displays the messages and the label is updated</p>
  
  <p><em>I tried w/ and w/o the while loops, both have the same result</em></p>
  
  <pre><code> private void recieveText(string _IPADDRESS)
          {
              //initialise multicast group and bind to interface
              Socket _listener_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
              IPEndPoint ipep = new IPEndPoint(IPAddress.Any, _PORT);
              _listener_socket.Bind(ipep);
              IPAddress localip = IPAddress.Parse("224.5.6.7");
              _listener_socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(localip, IPAddress.Any));
  
              //recieve data to multicast group
              //while (true)
              //{
              //while (_listener_socket.Connected)
              //{
                  label1.Text = "listening...";
                  byte[] b = new byte[1024];
                  _listener_socket.Receive(b);
                  label1.Text = "message recieved";
                  redBox.AppendText("\n---------------------------------\n New Message :\n");
  
                  char[] chars = new char[b.Length / sizeof(char)];
                  System.Buffer.BlockCopy(b, 0, chars, 0, b.Length);
  
                  string t = new string(chars).Trim();
                  redBox.AppendText(t);
                  redBox.AppendText("\n----------------------------------\n\n");
              //}
              //}
          }
  </code></pre>