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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:58:07+00:00 2026-06-09T11:58:07+00:00

I am using Parallel.ForEach on WCF service that hosted in IIS . As far

  • 0

I am using Parallel.ForEach on WCF service that hosted in IIS .

As far as I know for each task in parallel loop, thread will be opened.

But IIS have restriction on numner of threads that can be opened. I think it’s 20.

So my question is : Does it recommeneded to use Parallel.ForEach on IIS processes ?

  • 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-09T11:58:09+00:00Added an answer on June 9, 2026 at 11:58 am

    As far as I’m aware there are a few issues when using TPL in IIS.

    First, IIS does not have a hard restriction on threads in its thread pool. It really depends on what the threads are doing (CPU bound, IO bound etc). So, the number of threads by itself doesn’t matter that much.

    Second, as I understand it, TPL will take threads from the thread pool. So, in effect, you are taking threads that could be used to service requests. Again, this could be bad depending on how much traffic you are consuming.

    Third, IIS application pools will recycle. When this happens, again as I understand it, IIS will freeze the state of the threads and move them to another process. This could have unintended effects on the threaded operations.

    Usually, you want to use TPL (Parallel.ForEach) because you have a long running process. For long running processes, it might be better to call another host (Windows Service) to do the heavy lifting. In a Windows Service, for example, you have more control over how you manage threads.

    Hope this helps.

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

Sidebar

Related Questions

We're using Parallel.foreach to consume items from a blocking collection. I know that by
I'm using C# with .net 4.0 Is ThreadPool.QueueUserWorkItem thread safe? Example: Parallel.ForEach(commands, commandModel =>
I am planning to use Parallel.ForEach on a DataTable so that each record can
I am using the Task Parallel Library to set up a chain of Tasks
I'm using TPL in my current project and using Parallel.Foreach to spin many threads.
My question centers on some Parallel.ForEach code that used to work without fail, and
I am using Parallel.ForEach and I am doing some database updates, now without setting
I am working on a application which downloads using 1) Parallel.ForEach(linklist, x => DownloadAsync(x));
So I'm working in c# 4.0 WPF application and using parallel foreach loops to
How would I register a PSOCK cluster (created using package Parallel) with foreach ?

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.