Pergunta

I've been doing some tests about the way a .NET C# application uses resources, like CPU or memory. I wrote some loops that calculate values for a large amount of numbers and I'm satisfied with the weight of the algorithm.

I have a Quad Core 2.4 GHz processor, but I've noticed that In Task Manager, my application is only using 25% of my CPU. Why isn't it using 100%? Does that mean that a .NET C# Application compiled in VS 2008 only supports Single Core CPU? Or is there a way that I can force it to use all CPUs?

Foi útil?

Solução 4

What about if i use Background-workers ,if i have CPU QuadCore 4CPU's can somebody write an example how could it react @ that CPU ?

Outras dicas

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

Unless you are doing parallel or multi threaded operations, then the programme won't 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

It will run at 1 core unless you specifically start some threading.

The easiest way is to push a method onto the ThreadPool.

   System.Threading.ThreadPool.QueueUserWorkItem(DoSomething);

   void DoSomething() { ... }

Use .NET 4.0 TaskLibrary which is designed for benefiting from multi-core processors.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top