views:

165

answers:

3

I have a multi core cpu but the .net app i wrote only uses one of the cores. how can i make it use more than one core when that option is available.

+6  A: 

This doesn't happen for free. Using multiple cores necessitates using multiple threads. You will have to explicitly add threading support to your program in order to use multiple cores simultaneously.

Here is a great article exploring how you can take advantage of multiple cores with managed code using the task parallel library (also known as the parallel extensions framework).

http://msdn.microsoft.com/en-us/magazine/cc163340.aspx

JaredPar
+4  A: 
m3rLinEz
A: 

@JaredPar gives an excellent answer. Under some circumstances, though, it may not we worth rewriting code to be multi-threaded. Multithreaded code is more complicated, and adds a whole slew of additional types of bugs to wrestle with.

However, in the simple case of a desktop application, it is sometimes worth leaving the second core of a dual core machine free, so that the operating system can use it for doing things like redrawing the screen for other applications, running the virus scanner, etc.

Not the answer you particularly wanted to hear, but a pragmatic one in certain cases nevertheless.

Bill Michell