Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe TPL will usually use one thread per core unless you specifically tell it to use more. It's <em>possible</em> that it will detect when that's not enough - e.g. in your case, where your tasks are going to spend most of their time waiting for data.</p> <p>Is there any reason you can't use asynchronous web fetching? I suspect there's no need to have a thread per task or even a thread per core here. TPL makes various aspects of asynchronous programming easier, with things like continuations.</p> <p>In terms of efficiency, is your application actually CPU bound? It sounds like you need to be getting the maximum appropriate level of parallelism at the network side - that's the bit to concentrate on, unless the calculations are really heavyweight.</p> <hr> <h1>UPDATES - NOT FROM ORIGINAL AUTHOR</h1> <p>The answer above is great as always but could be misleading as it does not have some important changes in .NET 4.0 CLR.</p> <p>As Andras says, current TPL implementation uses the thread pool hence will use as many threads as required (<strong>number of cores is irrelevant now</strong>):</p> <blockquote> <p>The Task Parallel Library (TPL) is a collection of new classes specifically designed to make it easier and more efficient to execute very fine-grained parallel workloads on modern hardware. TPL has been available separately as a CTP for some time now, and was included in the Visual Studio 2010 CTP, but in those releases it <strong>was</strong> built on its own <em>dedicated work scheduler</em>. For Beta 1 of CLR 4.0, the default <strong>scheduler for TPL will be the CLR thread pool</strong>, which allows TPL-style workloads to “play nice” with existing, QUWI-based code, and allows us to reuse much of the underlying technology in the thread pool - in particular, the thread-injection algorithm, which we will discuss in a future post.</p> </blockquote> <p>From:</p> <p><a href="http://blogs.msdn.com/b/ericeil/archive/2009/04/23/clr-4-0-threadpool-improvements-part-1.aspx" rel="noreferrer">http://blogs.msdn.com/b/ericeil/archive/2009/04/23/clr-4-0-threadpool-improvements-part-1.aspx</a></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. 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