Parallel.foreach vs foreach in c#
what is difference between parallel.foreach vs foreach in c# with example
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Raja TRank #685 · 3.5K reputationPosted Sep 2, 2015, 4:53 AM EDT
Foreach loop:
Iterations takes place sequentially one by one
foreach loop is run from a single Thread.
foreach loop is defined in every framework of .NET
Execution is slower
Parallel.ForEach:
Execution takes place in parallel way.
Parallel.ForEach uses multiple Threads.
Parallel.ForEach is defined in .Net 4.0 and above frameworks.
Execution is faster3
more details check out bellow urls
Devinder KumarRank #3,035 · 475 reputationPosted Sep 29, 2015, 8:17 PM EDT