public void updateLoop()
	{
		// Start the timer.
		timer.start();

		// Loop as long as the window is visible.
		while (isVisible() && !exit)
		{
			// Update the timer.
			timer.update();

			// Calculate the startup time.
			DebugManager.getInstance().setPhaseStartTime();

			// Handle the mouse and keyboard input.
			handleInput();

			// Calculate the used time by the physics update function.
			DebugManager.getInstance().setPhaseTime(1);

			// Calculate the used time by the body update function.
			DebugManager.getInstance().setPhaseTime(2);

			// Draw all Objects.
			draw();

			// Update the screen manager.
			_ScreenManager.update(timer);
			// Update the Window.
			window.update();

			// Calculate the used time at end of the game loop. FIX THE FPS COUNTER!!!
			DebugManager.getInstance().setPhaseEndTime();

			// Sleep some time.
			try
			{
				// The time left.
				int sleep = TimeSpan.FromMilliseconds(TimePerFrame).Subtract(timer.getElapsedTime()).Milliseconds();
				// If there is time left, sleep.
				if (sleep > 0)
				{
					Thread.sleep(sleep);
				}
			}
			// Catch the exceptions.
			catch (InterruptedException e)
			{
				System.out.println(this + ": Interrupted Error. (" + e + ")");
			}
		}

		// If to exit, exit.
		if (exit)
		{
			// Turn off the program.
			System.exit(0);
		}

		// Stop the timer.
		timer.stop();
	}