I have a program that scans a network, it does so by using a lot of tasks (and parallel foreaches) that wait for data to return from the network. The problem is that although I know that these tasks barely use any CPU processing, the CLR doesn't and it insists to start off very slowly (especially since this is running on a two core CPU).
How can I force the CLR to start more tasks at the same time? Currently the program is waiting a lot, how can I make it open more connections at the same time?
You can either use async IO which does not require the TPL to start new threads, or you can start threads manually, or you can use ThreadPool.SetMinThreads. Don't use the last solution though because this is a process-wide setting. Don't pick a global solution for a local problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With