title: multithread with access to "shared" listbox
body: <p>the problem is simple I have GUI c#/xaml app and I want to run GUI in one thread and some method ( infinite loop ) in another thread.
  And I need to modify element in GUI ( listbox ) from second thread. 
  I tried create global variable and some other tips from web, but nothing run well.</p>
  
  <p>now I have something like:</p>
  
  <pre><code>public delegate void InvokeDelegate(listdata Mujlist);
  //in global scope
  // and in Window class
  public void UpdateList(listdata Mujlist)
  {
      mujlistbox.DataContext = Mujlist;
  }
  // and in the second thread this
  object[] obj = new object[1];
  obj[0] = Mujlist;
  mujlistbox.BeginInvoke(new InvokeDelegate(UpdateList), obj);
  </code></pre>
  
  <p>this maybe do a job well, BUT I can't try this, because VS 2010 find error</p>
  
  <pre><code>Error 1 'System.Windows.Controls.ListBox' does not contain a definition for 'BeginInvoke' and no extension method 'BeginInvoke' accepting a first argument of type 'System.Windows.Controls.ListBox' could be found (are you missing a using directive or an assembly reference?)   D:\..\MainWindows.xaml.cs 85 28 WPFChat
  </code></pre>
  
  <p>BUT System.Windows.Forms <strong>have</strong> this <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.aspx" rel="nofollow">method</a>, so I am confused with <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx" rel="nofollow">this</a>.</p>
  
  <p>So, question is How can I simply update a listbox in "GUI thread" from child thread?</p>
  
  <p>Where do I mistakes? Is there better way how do this? How?</p>