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

  • SEARCH
  • Home
  • 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 1104113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:26:21+00:00 2026-05-17T01:26:21+00:00

I have a data grid in a view that is bound to a List

  • 0

I have a data grid in a view that is bound to a List in a viewmodel. I have a lot of data to retrieve for the list, so I want to break it up into many small retrievals instead of one big one.

I want this to happen on a background thread with the UI updating (the grid binding the new data) at the end of each batch retrieved.

At the end of each retrieval, I am doing a List.AddRange() on the private backer, then raising the OnPropertyChanged event passing the name of the public property that the grid is bound to.

Initially I tried this with 6 iterations that retrieve 100 items each. When running in the background, the UI would update after the first 100, but then not update the last 500 (even though the data was successfully added to the underlying list in the viewmodel).

Thinking that I had some issues with marshalling to the UI thread, I ran it sychroneously, expecting it to either work as expected (albeit blocking the UI during each retrieval) or block the UI during all the retrievals – but in either case, updating at the end to show 600 items. However, it ends up doing the same thing as when I run it in the background – only updates the first 100 and not the rest.

Below is the method I am using with both attempts, the top half being the background version commented out.

What am I doing wrong?

public void StartDataStream()
{
    //Task<List<Car>> task = _taskFactory.StartNew(this._retrieveData);

    //task.ContinueWith(t =>
    //{
    //    if (this._cars == null) this._cars = new List<Car>();

    //    this._cars.AddRange(t.Result);
    //    base.OnPropertyChanged("Cars");

    //    this.iterations += 1;
    //    if (iterations < 6) StartDataStream();
    //});

    if (this._cars == null) this._cars = new List<Car>();

    this._cars.AddRange(this.GetCarList(eq,s,e));
    base.OnPropertyChanged("Cars");

    this.iterations += 1;

    if (iterations < 6) StartDataStream();
}
  • 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-17T01:26:21+00:00Added an answer on May 17, 2026 at 1:26 am

    Have you tried using an ObservableCollection<T> rather than a List<T>

    I assume you have a public property called Cars similar to…

    public List<Car> Cars{
    
       get { return this._cars;}
       set
       {
          this._cars = value;
          base.OnPropertyChanged("Cars");
       }
    
    }
    

    If not this will not actually do anything…base.OnPropertyChanged("Cars");

    Extension Method AddRange for ObservableCollection

    public static class Extensions
    {
        public static void AddRange(this ObservableCollection obj, List<T> items)
        {
            foreach (var item in items)
              obj.Add(item);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.