Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:43:07+00:00 2026-05-16T14:43:07+00:00

I am gathering data in a separate Task and I want to data bind

  • 0

I am gathering data in a separate Task and I want to data bind the result to a GUI component using an ObservableCollection<>. So my code goes something like this:

private ObservableCollection<MyItem> _items;
public ObservableCollection<MyItem> Items
{
  get { return _items; }
  set
  {
    if (_items.Equals(value))
    {
      return;
    }
    _items = value;
    RaisePropertyChanged("Items");
  }
}

private void LoadData()
{
  Task task = Task.Factory.StartNew(() =>
  {
    ObservableCollection<MyItem> itms = _htmlParser.FetchData(...);

    Dispatcher.CurrentDispatcher.Invoke((Action)delegate
    {
      Items = itms;
    });
  });
}

The data is fetched from a component doing some HTTP requests. The error I am getting is:
Must create DependencySource on same Thread as the DependencyObject.

I am using the MVVM Light toolkit framework. I also tried to send the result as a message, but that ended up in the same error message. Any ideas or pointers?

EDIT: Here’s the issue:

public class MyItem
{
  public string Id { get; set; }
  public string Name { get; set; }
  public BitmapImage Image { get; set; }  // <--- A big No No because it inherits from the DependencyObject
  public Uri Uri { get; set; }
}

I changed the BitmapImage to a byte[] data type.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:43:08+00:00Added an answer on May 16, 2026 at 2:43 pm

    The exception you’re getting (“Must create DependencySource on same Thread as the DependencyObject”) indicates that something’s being created on a background thread and used on the UI thread. Are there any UI controls being created and stored in the collection for use by the UI?

    I see that the ObservableCollection itself is being created on a background thread, but I don’t think that’s the issue — unfortunately I’m not in the office to code and confirm that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am gathering data from youtube's gdata API and would like to use the
I'm having issues gathering data using JSON on the Songkick API. I'm really new
I'm just writing a small, data gathering application, and I want to export the
First of all, there is no code with me ... I'm gathering required data
Context : I'm trying to create a pie chart using jqPlot, gathering data from
I have my winform application gathering data using databinding. Everything looks fine except that
So I'm trying to automate a pretty tedious data gathering process from hundreds of
the question is one of design. i'm gathering a big chunk of performance data
I'm gathering some info from some cisco devices using python and pexpect, and had
I'm gathering data with the Facebook API and get_object requests with Koala are slow,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.