Deleted RRS feed

All replies

  • You cannot control the # of threads in the threadpool. This is managed by the system. You can create your own "thread pool" although I cannot imagine why you would. You can also use a Task and create your own TaskScheduler to limit concurrency (the TaskScheduler docs have an example for just this scenario).

    But you don't need to do any of this. Parallel.ForEach accepts a ParallelOptions parameter. This type has a property that specifies how much parallelism you want and therefore how may "threads" are run at any one time. Adjust this property value and you accomplish the same thing as using your own limited thread pool.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, February 11, 2019 2:56 PM