title: Asynchronous update to ObservableCollection items
body: <p>I'm new to multithreading and WPF.</p>
  
  <p>I have an <code>ObservableCollection&lt;RSSFeed&gt;</code>, at app startup items are added to this collection from UI thread. Properties of RSSFeed are bind to WPF ListView. Later, I want to update each RSSFeed asynchronously. So I'm thinking of implementing something like <code>RSSFeed.FetchAsync()</code> and raising PropertyChanged on its updated properties.</p>
  
  <p>I know that ObservableCollection doesn't support updates from threads other than the UI thread, it throws NotSupportedException. But since I'm not manipulating the ObservableCollection itself but rather updating properties on its items, can I expect this to work and see ListView items updated? Or would it threw an exception anyway due to PropertyChanged? </p>
  
  <p><strong>Edit:</strong> code</p>
  
  <p>RSSFeed.cs   </p>
  
  <pre><code>public class RSSFeed
  {
      public String Title { get; set; }
      public String Summary { get; set; }
      public String Uri { get; set; }        
      public String Encoding { get; set; }
      public List&lt;FeedItem&gt; Posts { get; set; }
      public bool FetchedSuccessfully { get; protected set; }        
  
      public RSSFeed()
      {
          Posts = new List&lt;FeedItem&gt;();
      }
  
      public RSSFeed(String uri)
      {
          Posts = new List&lt;FeedItem&gt;();
          Uri = uri;
          Fetch();
      }
  
      public void FetchAsync()
      { 
          // call Fetch asynchronously
      }
  
      public void Fetch()
      {
          if (Uri != "")
          {
              try
              {
                  MyWebClient client = new MyWebClient();
                  String str = client.DownloadString(Uri);
  
                  str = Regex.Replace(str, "&lt;!--.*?--&gt;", String.Empty, RegexOptions.Singleline);
                  FeedXmlReader reader = new FeedXmlReader();
                  RSSFeed feed = reader.Load(str, new Uri(Uri));
  
                  if (feed.Title != null)
                      Title = feed.Title;
                  if (feed.Encoding != null)
                      Encoding = feed.Encoding;
                  if (feed.Summary != null)
                      Summary = feed.Summary;
                  if (feed.Posts != null)
                      Posts = feed.Posts;
  
                  FetchedSuccessfully = true;
              }
              catch
              {
                  FetchedSuccessfully = false;
              }
  
          }
      }
  </code></pre>
  
  <p>UserProfile.cs</p>
  
  <pre><code>public class UserProfile : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
      public event CollectionChangeEventHandler CollectionChanged;
  
      private ObservableCollection&lt;RSSFeed&gt; feeds;
      public ObservableCollection&lt;RSSFeed&gt; Feeds 
      { 
          get { return feeds; }
          set { feeds = value; OnPropertyChanged("Feeds"); }
      }
  
      public UserProfile()
      {
          feeds = new ObservableCollection&lt;RSSFeed&gt;();
      }
  
      protected void OnPropertyChanged(string name)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (handler != null)
          {
              handler(this, new PropertyChangedEventArgs(name));
          }
      }
  
      protected void OnCollectionChanged(RSSFeed feed)
      {
          CollectionChangeEventHandler handler = CollectionChanged;
          if (handler != null)
          {
              handler(this, new CollectionChangeEventArgs(CollectionChangeAction.Add, feed));
          }
      }
  }
  </code></pre>
  
  <p>MainWindow.xaml.cs</p>
  
  <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged
  {
      // My ListView is bound to this
      // ItemsSource="{Binding Posts}
      public List&lt;FeedItem&gt; Posts
      {
          get 
          {
              if (listBoxChannels.SelectedItem != null)
                  return ((RSSFeed)listBoxChannels.SelectedItem).Posts;
              else
                  return null;
          }
      }
  
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          // here I load cached feeds
          // called from UI thread
  
          // now I want to update the feeds
          // since network operations are involved, 
          // I need to do this asynchronously to prevent blocking the UI thread
      }
  
  }
  </code></pre>
  
  <p>Thanks.</p>