tag:blogger.com,1999:blog-1185326540821386800.post8609274258157036349..comments2023-03-08T11:47:08.311+00:00Comments on Diabolical: The Shooter: GameTime in another ThreadJohn C Brownhttp://www.blogger.com/profile/00595025767497289755noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-1185326540821386800.post-75429117742112075272012-12-03T08:56:20.353+00:002012-12-03T08:56:20.353+00:00On your first point about using static members. I...On your first point about using static members. I find this causes me problems using the wrong instance for the thread I am running in. Especially if the same method can be called from multiple threads.<br /><br />I agree I end up passing GameTime and Random as parameters to lots of methods but as I said above, with thread safety I take no chances!<br /><br />Threading problems come up and bite me unexpectedly, especially on the Xbox if I have been testing it first on Windows.John C Brownhttps://www.blogger.com/profile/00595025767497289755noreply@blogger.comtag:blogger.com,1999:blog-1185326540821386800.post-10578830502208679312012-12-03T08:48:26.881+00:002012-12-03T08:48:26.881+00:00I have learnt when dealing with thread safety to e...I have learnt when dealing with thread safety to err on the side of caution!<br /><br />My understanding from the forum post I link to above is that GameTime is not thread safe!<br /><br />See the second paragraph of Shawn Hargreaves second comment:<br />'If you are for some reason running game logic outside of Update (for instance in an async multithreaded design) I don't know why you would use GameTime at all. A Stopwatch would be more appropriate for that scenario.'<br />John C Brownhttps://www.blogger.com/profile/00595025767497289755noreply@blogger.comtag:blogger.com,1999:blog-1185326540821386800.post-6410353472074892932012-12-02T21:43:00.085+00:002012-12-02T21:43:00.085+00:00Why not just assign game time to a static member?
...Why not just assign game time to a static member?<br /><br />I just do this in my screenManager ...<br /><br />Global3DGame.GameTime = gameTime;<br /><br /><br />My character animation is in another thread and i pass game time that way. I also use it to avoid having to pass the same darn thing around to everything. <br />Anonymousnoreply@blogger.com