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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:03:16+00:00 2026-06-04T21:03:16+00:00

And by "same thing" I mean do these two operations basically do the same

  • 0

And by "same thing" I mean do these two operations basically do the same work, and it just boils down to which one is more convenient to call based on what you have to work with? (i.e. a list of delegates or a list of things to iterate over)? I’ve been searching MSDN, StackOverflow, and various random articles but I have yet to find a clear answer for this.

EDIT: I should have been clearer; I am asking if the two methods do the same thing because if they do not, I would like to understand which would be more efficient.

Example: I have a list of 500 key values. Currently I use a foreach loop that iterates through the list (serially) and performs work for each item. If I want to take advantage of multiple cores, should I simply use Parallel.ForEach instead?
Let’s say for arguments’s sake that I had an array of 500 delegates for those 500 tasks – would the net effect be any different calling Parallel.Invoke and giving it a list of 500 delegates?

  • 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-06-04T21:03:19+00:00Added an answer on June 4, 2026 at 9:03 pm

    Parallel.ForEach goes through the list of elements and can perform some task on the elements of the array.

    eg.

    Parallel.ForEach(val, (array) => Sum(array));
    

    Parallel.Invoke can invoke many functions in parallel.

    eg.

    Parallel.Invoke(
    () => doSum(array),
    () => doAvg(array),
    () => doMedian(array));
    

    As from the example above, you can see that they are different in functionality. ForEach iterates through a List of elements and performs one task on each element in parallel, while Invoke can perform many tasks in parallel on a single element.

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

Sidebar

Related Questions

Brief: When academic (computer science) papers say "O(polylog(n))", what do they mean? I'm not
Possible Duplicate: What does the Visual Studio "Any CPU" target mean? I've noticed that
I have a slew of makefile targets that do the same thing: ${SOME_FILE}: ${FILES}
In Jesse Liberty's Learning C# book, he says "Objects of one type can be
I have functions that conceptually all return the same thing, but the result can
Hi I've got something like the following HTML: <div class="container"> <img src="first.png" /> <img
Well, I got something like this: HTML: <div id="main" class="underline" >Hello</div> JavaScript: $('div').live('click', function(){
My HTML: <div id="parent"> <div id="child">cx</div> </div> When I use jQuery $('#parent').mouseout(function(){ //something here
$("#multiselect").hide(); $("#multiselect_container").append('<img id="loader" src="/loader.gif" />'); Above 2 functions inside the $("#list").click() block are being
The "joke" question Joel asked during podcast #58 made me all nostalgic for Logo,

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.