C# Cursor stuck on busy state

Posted by Ben on Game Development See other posts from Game Development or by Ben
Published on 2013-05-02T21:25:41Z Indexed on 2013/07/01 23:16 UTC
Read the original article Hit count: 278

Filed under:
|

So I implemented a fixed time step loop for my C# game. All it does at the moment is make a square bounce around the screen. The problem I'm having is that when I execute the program, the window doesn't allow me to close the program and the cursor is stuck on the busy icon. I have to go into visual studio and stop the program manually.

Here's the loop at the moment public void run() { int updates = 0; int frames = 0; double msPerTick = 1000.0 / 60.0; double threshhold = 0; long lastTime = getCurrentTime(); long lastTimer = getCurrentTime();

        while (true)
        {
            long currTime = getCurrentTime(); 
            threshhold += (currTime - lastTime) / msPerTick;
            lastTime = currTime;

            while (threshhold >= 1)
            {
                update();
                updates++;
                threshhold -= 1;                                     
            }

            this.Refresh();
            frames++;

            if ((getCurrentTime() - lastTimer) >= 1000)
            {          
                this.Text = updates + " updates and " + frames + " frames per second";
                updates = 0;
                frames = 0;
                lastTimer += 1000;
            }
        }
    }

© Game Development or respective owner

Related posts about c#

Related posts about game-loop