Threading limits and other recommendations
So, it sounds like using multiple threads can really speed up your application’s performance. You should probably start replacing all your
foreach loops with
Parallel.ForEach loop and start calling all your services and helper methods on thread pool threads, right? Are there any limits and what are they? Well, when it comes to threading, there absolutely are limits.
The number of threads that can execute simultaneously is limited by the number of processors and processor cores on the system. There is no way around hardware limitations, as the CPU (or virtual CPU when running on a virtual machine) can only run so many threads. In addition, your application must share these CPUs with other processes running on the system. If your CPU has four cores, it is actively running five other applications, and your program is trying to execute a process with multiple threads, the system is not likely to accept more than one of your threads at...