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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:42:29+00:00 2026-06-13T17:42:29+00:00

I looked at microsoft’s tutorial on Tasks on MSDN… It was good for what

  • 0

I looked at microsoft’s tutorial on Tasks on MSDN… It was good for what it showed, but I still have questions In there example… found at this URL: MSDN Link

They show an example where they show a Parallel.ForEach() static method call. In that method call they have four parameters… Does the first Parameter have to be an Array of Ints? Or could it be a collection or object of any kind that all the thread are working on? Looks like the second parameter is an Action, which is a delegate that doesn’t return a value (or a void). What the heck is that second variable for? Thread Local initializer? Why Initialize to 0? What the hell is being set here? The 3rd parameter is just a delegate (or a function point as I like to think of them with) is the right side of the lambda expression the actual function? for instance, could I put the name of an actual function on that side without having to write it out right there? For example…

    public int localSum(int n, ParallelLoopState loopState, int localSum) {
        localSum += n;
        Console.WriteLine("Thread={0}, n={1}, localSum={2}", Thread.CurrentThread.ManagedThreadId, n, localSum);
        return localSum;
    }

(n, loopState, localSum) => localSum(int n, ParallelLoopState loopState, int localSum),
  • 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-13T17:42:30+00:00Added an answer on June 13, 2026 at 5:42 pm

    Looks like this overload:

    public static ParallelLoopResult ForEach<TSource, TLocal>(
        IEnumerable<TSource> source,
        Func<TLocal> localInit,
        Func<TSource, ParallelLoopState, TLocal, TLocal> body,
        Action<TLocal> localFinally
    )
    

    where you have:

    Parameters
    
    source
        Type: System.Collections.Generic.IEnumerable<TSource>
    
        An enumerable data source.
    
    localInit
        Type: System.Func<TLocal>
    
        The function delegate that returns the initial state of the local data for each task.
    
    body
        Type: System.Func<TSource, ParallelLoopState, TLocal, TLocal>
    
        The delegate that is invoked once per iteration.
    
    localFinally
        Type: System.Action<TLocal>
    
        The delegate that performs a final action on the local state of each task.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I looked at this example http://msdn.microsoft.com/en-us/library/bb399420.aspx and clicked on DataContext.CreateDatabase which brought me to
I have looked at two of Microsoft's tutorials for MVC. In one tutorial they
I looked around but haven't found an answer to this. I have a CentOS
I looked through other StackOverFlow questions, but I'm a little confused. I'm trying to
I did looked at this question, but the asker didn't got any reply. Still,
I have looked and thought about good and bad points of my past designs
I am trying to begin the Direct3D tutorial at http://msdn.microsoft.com/en-us/library/windows/apps/hh780567.aspx . I created my
I have looked every where but I can't get IE6 to display a transparent
Could anyone answer on these questions? 1) There is a Microsoft's class: SafeHandle.cs I
I've looked around and tried many suggestions but none have worked. I recently migrated

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.