Paul Burg

Is there any way to implememt multi-threaded programming into a XNA based game As multi-core processors become more prevalent, the ability to take advantage of that would be rather useful. Does XNA implement multi-threaded design behind the scenes, a.k.a. in the fundamental way the Game class works

I was thinking that for my program, I have multiple GameComponent classes for which the update functions could be run in parrallel. Is there anyway to specify that I've looked up information on righting multi-threaded applications in C#, but I'm not sure if those approaches are compatible with the XNA game loop design (in fact I imagine they would not be).

Re: XNA Game Studio Express Multithreading in XNA


It certainely is possible. Have a look at the .Net Threading Class articles.

Re: XNA Game Studio Express Multithreading in XNA

Peter D.

Don't forget to also set the thread affinity or it will run on the same processor as your main process. Joel's post below is correct of course. The thread affinity is ignored on a PC due to windows deciding which thread runs on which processor. This is logical because windows may have one or more programs and processes running and each one runs in it's own thread. The 360 runs the kernel and your games and that's it so it uses a couple of threads for itself and leaves 4 free for games to use.

Re: XNA Game Studio Express Multithreading in XNA

Joel Martinez

I believe the thread affinity setting only works on the xbox 360 ... on windows you've got to rely on the OS to distribute the workload.