53284

Limiting number of tasks running at once

Question:

I have to run about 150 tasks. Right now the app is using only 25 threads per core and I need that to be a higher number. Is it possible to increase that limit ?

Answer1:

The only way to control the actual number of threads that will actually be created is to implement your own <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.aspx" rel="nofollow">TaskScheduler</a> subclass where you can control the creation and scheduling of the threads on which to execute tasks. The default implementation uses thread pool threads along with several heuristics to determine the maximum number of threads to schedule per core.

Honestly, I'd be amazed if you can beat the default implementation. Are you doing any I/O in these tasks? Are you using async I/O?

Recommend

  • Resolving parameter type in Roslyn
  • Synchronization context for Task.Delay
  • creating a UI in background thread WPF?
  • Is it OK to write code after [super dealloc]?
  • Error:Execution failed for task ':app:dexDebug'. when importing ParseLoginUI as a module
  • How to create a generic Task.ContinueWith extension method
  • Attemping to change attributes of $(this) inside success function
  • Autohotkey script running program with command line arguments
  • get all processes in parallel
  • Using same constraints in multiple classes
  • LiveData is abstract android
  • Write output of for loop to multiple files
  • Plotting densities in R
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Salesforce Different WSDL files and when to use
  • android google indoor map
  • presentShareDialogWithParams posts to FB wall, but callback handler results say error
  • Not able to aggregate on nested fields in elasticsearch
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Django simple Captcha “No module named fields” error
  • Caching attributes in superclass
  • Time complexity of a program which involves multiple variables
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • Checking free space on FTP server
  • Using $this when not in object context
  • Nant, Vault & Windows Integrated Authentication
  • req.body is undefined - nodejs
  • C# - Serializing and deserializing static member
  • Bug in WPF DataGrid
  • Incrementing object id automatically JS constructor (static method and variable)
  • Symfony2: How to get request parameter
  • How to limit post in wp_query
  • jQuery tmpl and DataLink beta
  • How can I estimate amount of memory left with calling System.gc()?
  • Delete MySQLi record without showing the id in the URL
  • Akka Routing: Reply's send to router ends up as dead letters
  • Is there a mandatory requirement to switch app.yaml?
  • Free memory of cv::Mat loaded using FileStorage API
  • Hits per day in Google Big Query
  • unknown Exception android