title: NetworkStream BeginRead / EndRead
body: <p>I'm really new to C# programming and I'm developing an application based on a TcpClient.</p>
  
  <p>I would like to know how to use BeginRead &amp; EndRead, I've already read MSN documentation but doesn't help.</p>
  
  <p>I've this :</p>
  
  <blockquote>
  <pre><code>    private void Send()
      {
          TcpClient _client = new TcpClient("host", 80);
          NetworkStream ns = _client.GetStream();
          ns.Flush();
          / ...
          ns.Write(buffer, 0, buffer.Length);
  
          int BUFFER_SIZE = 1024;
          byte[] received = new byte[BUFFER_SIZE];
          ns.BeginRead(received, 0, 0, new AsyncCallback(OnBeginRead), ns);
      }
  
      private void OnBeginRead(IAsyncResult ar)
      {
          NetworkStream ns = (NetworkStream)ar.AsyncState;
          int BUFFER_SIZE = 1024;
          byte[] received = new byte[BUFFER_SIZE];
          string result = String.Empty;
  
          ns.EndRead(ar);
  
          int read;
          while (ns.DataAvailable)
          {
              read = ns.Read(received, 0, BUFFER_SIZE);
              result += Encoding.ASCII.GetString(received);
              received = new byte[BUFFER_SIZE];
          }
          result = result.Trim(new char[] { '\0' });
          // Want to update Form here with result
      }
  </code></pre>
  </blockquote>
  
  <p>How can I update a Form component using result ?</p>
  
  <p>Thanks for help.</p>