C#C
C#4mo ago
Yesn't

✅ Why won't the loop loop?

public class Game
{
    public Task gameloop = Task.Factory.StartNew(() =>
    {
        // new world
        World world = new World(10, 10);
        world.EntityManager.Spawn(0, 1, new Entity() { x = 0, y = 1, movement = new Vector2(5, 5) });
        while (true)
        {
            world.tick();
        }
    }, TaskCreationOptions.LongRunning);
}
namespace OpenWarfare
{
    internal class Program
    {
        static void Main(string[] str)
        {
            Game game = new Game();
            game.gameloop.Start();
        }
    }
}

I'm using the console template + old coding style. I expected the game to run in a loop, however the game exited. The code above is my Program.cs btw
Was this page helpful?