title: Clearing a listbox
body: <p>I'm working on a chat-program. The chat works. The GUI on the client-side has 1 textarea to show all chat messages, 1 textfield and 1 button to send a message and 1 listbox which contains all acutally connected clientnames with the server.
  If one client has connected to the server, the server sends a specific code which calls a "requestClientnamelist()"-method on the clientside, which requests the actually clientnamelist from the server and put this list in his listbox.</p>
  
  <p>And here is my problem:
  Before i refill the listbox with the actually clientnamelist, i want to clear this listbox first so i have not any twice names in this listbox. But the listbox1.Clear() method does not clean anything! The filling of the listbox works, but the clearing of the old clientnamelist does not work...</p>
  
  <p>Here is my code (This code called from a different thread (not the GUI-Thread!)):</p>
  
  <pre><code>                        // Clear and refill Clientnamelist in mainframe
                          try {
                              mainframe.Invoke((Action)delegate {
                                  mainframe.listBox1.Items.Clear();
  
                                  for (int i = 0; i &lt; client.clientnameList.Count; i++) {
                                      mainframe.listBox1.Items.Add(client.clientnameList[i]);
                                  }
  
                              });
                          } catch (ObjectDisposedException e) {
                              Console.WriteLine(e.StackTrace);
                          }
  </code></pre>