title: Global variable returns null after click event
body: <p>I am writing a client-server application in C# but I have a problem. I have start_server and connect_to_server buttons in the same form. I am trying to add all connected clients into a list when connect_to_server button is clicked. Client can be added into list in connect_to_server button click event but when event is finished list returns null or empty. What can I do? Is the problem about declaring the list variable? Or should I implement something different? Can somebody help me? Thanks.</p>
  
  <pre><code>private void btnStartClient_Click(object sender, EventArgs e)
  {
      try
      {
           richTextBox1.AppendText("Connected to server!" + "\n");
           m_connectedIpAddresses.Add(((IPEndPoint)sock.Client.LocalEndPoint).Address.ToString());
      }
      catch (Exception e1)
      {
              MessageBox.Show("Cannot connect to server");
      }
  }
  
  private void btnAnotherButton_Click(object sender, EventArgs e)
  {
      int count = m_connectedIpAddresses.Count;
  }
  </code></pre>
  
  <p>'count' variable returns zero. I need number of total connected clients in here.</p>