lifeamit

please tell me that how to delete my threads (formerly threats)



Re: XNA Framework how to delete the threats?

dczraptor

Do you mean threads You shouldn't be multi-threading XNA applications in any case though... Can you be more specific




Re: XNA Framework how to delete the threats?

Catalin Zima

Yes, he needs to be more specific!

dczraptor: why shouldn't you multi-thread your XNA application how elso would you get to use the power of the 4 available hardware threads on teh xbox (2 are reserved, we only have 4 available)





Re: XNA Framework how to delete the threats?

dczraptor

sorry, i meant for windows, and as a general guideline because you could start running into funny problems when you render if you aren't careful.




Re: XNA Framework how to delete the threats?

--Alan---

As a general guideline if you want high performing code you should multithread. You'd be stupid not to! Of course there is a steep learning curve, but it is something well worth learning to do right.




Re: XNA Framework how to delete the threats?

dczraptor

That's true, but how many of us are writing the next Gears of War Unless you have some really clunky code or if you're networking, a lot(obviously there will be people who require the full power of the processor and GPU) of the people who use XNA will be fine with just a single thread. Correct me if I'm wrong here, I'd like to know more.




Re: XNA Framework how to delete the threats?

waruwaru

Rocket Commander is multi-threaded (not to imply that Rocket Commander isn't as fun as GoW ;)).  If the first multi-threaded program you write is Geat of War, you will be in for a world of hurt.   Simpler program is a good place to learn about multi-threading.  No doubt that some beginners will get in trouble doing thread programming, but that's not a good reason to discourage people from learning about threads.  Btw, I think alot of people in these forums have day jobs as software engineers and/or works in game companies.

EDIT: Here is an article showing you how to create and terminate threads in C#

http://msdn2.microsoft.com/en-us/library/7a2f3ay4.aspx






Re: XNA Framework how to delete the threats?

dczraptor

Looks like I was wrong :/ I've done multi-threaded apps before, but I was just under the impression that most games that people would create with xna wouldn't involve multithreading. I guess i should do my research before making baseless claims next time :)




Re: XNA Framework how to delete the threats?

Shawn Hargreaves - MSFT

For what it is worth, neither SpaceWar nor the upcoming racing starter kit use more than a single thread.

You have to consider what your goal is here. If your main objective is to push the 360 as far as it can possibly go, then yes, you need to use multiple threads. If your game isn't parallized, all but one of those lovely CPU cores will be sat idle.

But what if your goal is just to make a fun game You certainly don't need multiple threads for that. It all depends on how performance intensive your game idea is. If you can make the game you want to make using just a single core, there is absolutely nothing wrong with doing that.

Also bear in mind that multithreaded programming is really, really hard! The CLR does some nice things to help around the edges, but fundamentally you still need to worry about nasty things like race conditions, deadlocks, and lock contention. It is also surprising how easily a bad threading implementation can actually slow down your game! It takes a lot of skill and careful design to parallise things well enough to get a big performance boost.







Re: XNA Framework how to delete the threats?

waruwaru

I was just thinking, besides performance reasons, threads are probably good in a loading screen (one for animations, one for load/decompressing resources). If we get networking APIs, separate threads will be useful for handle network traffics. :)




Re: XNA Framework how to delete the threats?

Shawn Hargreaves - MSFT

It's a tradeoff. It can sometimes be convienient to write multiple overlapping pieces of program behavior in separate threads, but other times it can be a real pain to deal with synchronising all your shared data structures to avoid races.

For what it's worth, my last commercial game (on Xbox 1, so there was no performance gain from multiple CPU cores) used threads for the loading screen animation, and for background music, but not for anything else. Networking in particular would have been much more of a pain if we'd tried to run it asynchronously to the game logic.

Threads can certainly be a performance gain when they let you take advantage of multiple CPU cores, but in terms of programming simplicity, my advice has to be steer as far clear as you possibly can!