Jump to content

Please help me with this error im getting

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Danthekilla

Danthekilla

    Newbie

  • Members
  • Pip
  • 1 posts
Well im trying to use this code
  using (Game2 game = new Game2())
                {
                    game.Run();
                }
Where Game1 is defined like this.
public class Game2 : Microsoft.Xna.Framework.Game

Now im trying to call it inside of another update loop.

So its got the main game running and then when i want to load this "Game2" inside the update loop of the first.
The idea was to start one game when a certain button was pressed and then it would run and not return to the update loop it was called from until it quit and when it did the first loop would just keep going.

So then i would kinda be able to step in and step out of different "Games"

But it gives me this error during runtime.
"Starting a second message loop on a single thread is not a valid operation."

Now i understand that why its happening (I think) (Because the message pump thing is sending messages to only the first and thats what the microsoft xna Game class plugs into???)

But i can't think of a way around it.. Any way would do.

Also i tryed opening it up in another thread and that just creates a 2nd window with the first and second both running...

Edited by Jaan, 09 July 2009 - 06:56 AM.
Please use code tags when you are posting your codes!


#2
gaylo565

gaylo565

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 268 posts
You could use a second thread but put the first one to sleep when you start the second one. You would need to restart I belive it is just
thread.Sleep(timespan.Infinite);
but you should probably check out the documentation on the method to make sure your doing it right. You could also join the 2 threads so that the one waits till the other one is finished and then starts automaticly. Dont remember the code off hand for a join but google it and you will get all the info you need.