Question

I made a launcher for my game and successfully found the code to launch the game. But for some reason it doesn't work. The error message is InvalidOperationException

Is there an easier way to do this? Or how can I fix this?

This is the code:

private void Startgame_Click(object sender, EventArgs e)
{
   using (Zombie_Shooter.GameCode game = new Zombie_Shooter.GameCode())
   {
       game.Run();
   }
}
Was it helpful?

Solution

Do you can try this ?

Thread thread = new Thread(() =>
{    
     Game1 game = new Game();    
     game.Run();
});


private void Startgame_Click(object sender, EventArgs e)
{
   thread.Start();
   thread.Join();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top