title: WPF thread and GUI how to access object from different thread?
body: <p>I have a thread that call an object that get some stuff from Internet. When this object is filled up with all information required, it raises an event with an object will all the information. The event is consumed by the controller that has started the thread.</p>
  
  <p>The returned object from the event is than added into a collection that is binded the the GUI via a View Model approach.</p>
  
  <p>The problem is that I can't use the CheckAccess with the binding... how can I fix the problem of using Object that has been created from an other thread of the main one?</p>
  
  <p>The error that I receive when I add the object to the collection of the main thread is :</p>
  
  <blockquote>
    <p>This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.</p>
  </blockquote>
  
  <p>This the the controller:</p>
  
  <pre><code>public class WebPingerController
  {
      private IAllQueriesViewModel queriesViewModel;
  
      private PingerConfiguration configuration;
  
      private Pinger ping;
  
      private Thread threadPing;
  
      public WebPingerController(PingerConfiguration configuration, IAllQueriesViewModel queriesViewModel)
      {
          this.queriesViewModel = queriesViewModel;
          this.configuration = configuration;
          this.ping = new Pinger(configuration.UrlToPing);
          this.ping.EventPingDone += new delPingerDone(ping_EventPingDone);
          this.threadPing = new Thread(new ThreadStart(this.ThreadedStart));
      }
  
  
      void ping_EventPingDone(object sender, QueryStatisticInformation info)
      {
          queriesViewModel.AddQuery(info);//ERROR HAPPEN HERE
      }
  
      public void Start()
      {
          this.threadPing.Start();
      }
  
      public void Stop()
      {
          try
          {
              this.threadPing.Abort();
          }
          catch (Exception e)
          {
  
          }
      }
  
      private void ThreadedStart()
      {
          while (this.threadPing.IsAlive)
          {
              this.ping.Ping();
              Thread.Sleep(this.configuration.TimeBetweenPing);
          }
      }
  }
  </code></pre>