title: How to bind a combo box to a collection asynchronously where the objects gets updated WPF
body: <p>I have created a WPF binding it was working fine but then I realised I needed a refresh button show when I call the SetUpData function I am getting this error: </p>
  
  <p>Additional information: This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.</p>
  
  <p>C#:</p>
  
  <pre><code>public async void GetShows(string serviceDocUri)
  {
  
      await Task.Run(() =&gt; _Shows = new ObservableCollection&lt;Show&gt;());
  
      await Task.Run(() =&gt; GetAllShowsWithPath("", directoryShowDoc)); //Error shows on this line
  }
  </code></pre>
  
  <p>More C#:</p>
  
  <pre><code>public MainWindow()
  {
      InitializeComponent();
      this.DataContext = Workspace.This;
  
      //Awaits the list of shows
      SetUpData();
  }
  </code></pre>
  
  <p>More C#:</p>
  
  <pre><code>private async void SetUpData()
  {
      await Task.Run(() =&gt; _VizManager.GetShows(_TrioLocalHost));
  
      //This is binded to my WPF combobox
      Workspace.This.TrioShow = _VManager._Shows;
  
  }
  </code></pre>
  
  <p>More C#:</p>
  
  <pre><code>private async Task GetAllShowsWithPath(string directoryPath, XmlDocument xmlDoc)
  {
      string siteRoot = "http://";
      foreach (XmlNode showNode in xmlDoc.SelectNodes("//atom:feed/atom:entry[atom:category/@term='show']/atom:title", nameSpaceManager_))
      {
          _Shows.Add(new Show { Title = "showTitle", ShowLink = "showLink", FullPath = "fullPath" });
      }
  
      foreach (XmlNode dirNode in xmlDoc.SelectNodes("//atom:feed/atom:entry[atom:category/@term='directory' and not(atom:category/@term='show')]/atom:title", nameSpaceManager_))
      {
          string dir = dirNode.InnerText;
          XmlDocument xmlDoc1 = new XmlDocument();
          string directoryPath1 = directoryPath + "/" + dir;
          string xml = "";
          string page = siteRoot + "/directory/shows" + directoryPath1 + "/";
          using (HttpClient client = new HttpClient())
          using (HttpResponseMessage response = await client.GetAsync(page))
          {
              response.Headers.Add("Accepts", "application/atomsvc+xml");
              using (HttpContent content = response.Content)
              {
                  string data = await content.ReadAsStringAsync();
                  if (data != null)
                  {
                      xml = data;
                  }
              }
          }
          xmlDoc1.LoadXml(xml);
          await this.GetAllShowsWithPath(directoryPath1, xmlDoc1);
      }
  }
  </code></pre>