Domanda

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();
   }
}
È stato utile?

Soluzione

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();
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top