multi-thread CPU usage in C# multi-thread CPU usage in C# multithreading multithreading

multi-thread CPU usage in C#


You may try to shift your program from workstation to server garbage collection mode. Currently you may use just one garbage collection thread.
The setup is explained here.
See this thread for an explanation/further details.
Do not expect 100 % CPU load after the change, but you will get closer to 100% and increase the spead of it.


The concurrency visualizer will help you here. You will see when each thread is executing, and if all threads are not executing you can see exactly why a specific thread is waiting. If you generate a lot of garbage, the GC may keep threads blocked leading to less than linear scaling. But you will only find out by making a real investigation.


I had the same issue while working with .NET Framework v2.0 then i changed the projects target framework to v4.0 it started with 100 % CPU load

Edit: You can watch the CPU usage per threads, simply with

Sysinternals Process Explorer

or

Process Hacker