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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:49:02+00:00 2026-05-27T07:49:02+00:00

Recently decided to write a quick windows form app to tag my MP3 files.

  • 0

Recently decided to write a “quick” windows form app to tag my MP3 files. Not done anything with parallelism since .Net 3.0, so I’m looking at the Parallel.ForEach method to deal with the UI locking I get when I’m using a standard foreach statement. Here’s an excerpt:

var i = 1;
var files = new List<string>(); // File list is populated using recursive method.

foreach(var f in files) {
    // Add a row
    var row = dgvList.Rows[dgvList.Rows.Add()];

    // Update label
    lblSummary.Text = string.Concat("Processing... ", i);
    // Do things with row

    // Increment progress bar
    progressBar.PerformStep();
    i++;
}

I’ve figured out the simple usage of Parallel.ForEach(), but I’m not sure I should be using that particular method to update the UI? Any suggestions?

  • 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-27T07:49:02+00:00Added an answer on May 27, 2026 at 7:49 am

    OK, I found the best way to achieve this is by running something like this:

    // Kick off thread
    Task.Factory.StartNew(delegate{
         foreach(var x in files) {
             // Do stuff
    
             // Update calling thread's UI
             Invoke((Action)(() => {
                  progressBar.PerformStep();
             }));
         }
    }
    

    I actually updated my code to populate a List within the foreach loop, then assign that to the daragrid via .DataSource, instead of working with the .Rows collection directly. Should have done that from the start really 🙂

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

Sidebar

Related Questions

I've been playing recently with Jython and decided to do some quick and dirty
I've recently decided that I just have to finally learn C/C++, and there is
i am quite familiar with Smarty and recently decided to use Zend framework in
I've been working with some event handling in Javascript and recently decided to migrate
The software group I currently work in has recently decided to start documenting our
This is starting to vex me. I recently decided to clear out my FTP,
I've been interested in D for a couple of years now and recently decided
I started a Rails project recently and decided to use RESTful controllers. I created
I'm a beginner (self-learning) programmer learning C++, and recently I decided to implement a
I recently started a new webforms project and decided to separate the business classes

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.