Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.paralleloptions.maxdegreeofparallelism(v=vs.110).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.threading.tasks.paralleloptions.maxdegreeofparallelism(v=vs.110).aspx</a></p> <blockquote> <p>By default, <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.parallel.for(v=vs.110).aspx" rel="noreferrer"><code>For</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.parallel.foreach(v=vs.110).aspx" rel="noreferrer"><code>ForEach</code></a> will utilize however many threads the underlying scheduler provides. Changing MaxDegreeOfParallelism from the default only limits how many concurrent tasks will be used.</p> </blockquote> <p>This means that setting <code>MaxDegreeOfParallelism</code> to the number of processors will in fact limit the capacity of the <code>Parallel.For</code> loop to use the optimal amount of threads for the work load. For example, I have a migration job that uses close to 60 threads on around 600 iterations of long-running code, a lot more than the <em>1 thread per processor</em> limit that you're trying to set.</p> <p><code>MaxDegreeOfParallelism</code> or <code>ThreadPool.SetMaxThreads</code> should only be used if you explicitly need to prevent more than a given number of threads from executing. For example, if using an Access database, I would set it to 64, because that's the maximum number of concurrent connections that can be handled by Access for a single process.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload