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 6004273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:14:25+00:00 2026-05-23T01:14:25+00:00

I have a WPF app with a listview control. The application basically loads a

  • 0

I have a WPF app with a listview control. The application basically loads a file into a list view. I then want to iterate through each listview element, highlighting the current row, and performing a certain task.

When the task is done I update another file and a panel with the results and move on to the next listview element.

I’ve done stuff like this in WinForms before, but I’m quite green when it comes to WPF. I guess my main concern is how to handle the second thread, other than the UI thread. Is the threading model any different in WPF?

Secondly, the program is essentially a loop through an ObservableCollection:

for (int i = 0 ; i < Collection.Count; i++)
{
   HighlightCurrentRowInListView();
   Collection[i].DoWork();
   PostWorkToPanel();

   // Bad loop around code
   if (i == (Collection.Count - 1))
   { i = -1; }
}

If I make a change to the collection (which is an ObservableCollection), how will the loop update? Whats the best iteration method, foreach, .ForEach(x=>x) for this context? The program should keep running until a “STOP” button or something is pressed.

  • 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-23T01:14:25+00:00Added an answer on May 23, 2026 at 1:14 am

    If you need info on the threading model see the respective MSDN page.

    Since you have an observable collection you can handle the CollectionChanged event, you can see if items have been added or removed so you can add or remove those from a workqueue that you could just take items from until it’s empty (while-loop).

    To change UI-Elements from the background thread you need to use the Dispatcher, see the threading model link i gave for help on that topic.

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

Sidebar

Related Questions

So, I have a WindowsFormsHost control in my WPF app (hosting a Dundas Chart)
I have a WPF App that implements a ListView. I would like to show
In WPF app I have a ListView : <ListView Height=100 Width=434 x:Name=lvItems ItemsSource={Binding ElementName=MainWindow,
In WPF app I have a ListView: <ListView Height=100 Width=434 Margin=0,2,0,0 x:Name=lvItems ItemsSource={Binding ElementName=MainWindow,
In WPF app I have a ListView which is connected with ObservableCollection ShQuCollection through
I have a ListView in my WPF app that is bound to a collection
I have a WPF app which snaps to screen edges (I just set the
I have a WPF App which is grinding to a halt after running out
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
This is an interesting conundrum. We have a WPF app that has a Vista-like

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.