What can I do to make the C # application take advantage of multiple processor cores?

I have done some tests on how a .NET C # application uses resources such as processor or memory. I have written several cycles that calculate values ​​for a large number of numbers, and I am pleased with the weight of the algorithm.

I have a 2.4 GHz quad-core processor, but I noticed that in the task manager, my application uses only 25% of my processor. Why doesn't he use 100%? Does this mean that the .NET C # application compiled in VS 2008 only supports a single core processor? Or is there a way I can get it to use all processors?

+6
performance c # cpu-usage
source share
4 answers

How about using background workers, if I have a QuadCore 4CPU CPU, can anyone write an example, how could he respond @ to this CPU?

+1
source share

It all depends on how you can change your code to use more than one core.

If you do not perform parallel or multithreaded operations, then the program will not use more than one core.

.NET 4 has a library that can help you: Parallel LINQ. For more information see this page: http://msdn.microsoft.com/en-us/library/dd997425.aspx

+5
source share

It will work with 1 core, unless you specifically start any thread.

The easiest way is to direct the method to ThreadPool.

System.Threading.ThreadPool.QueueUserWorkItem(DoSomething); void DoSomething() { ... } 
+2
source share

Use the .NET 4.0 TaskLibrary , which is designed to use multi-core processors.

+2
source share

All Articles