Exemplo n.º 1
0
        public void Run()
        {
            int frames        = 0;
            int previousTicks = 0;

            AudioMixer.StartMixer(44100, 0x800); // 1/5th a second audio buffer

            while (Running)
            {
                while (Events.Poll())
                {
                    ;
                }

                gui.Paint();
                Video.Update();

                if (++frames >= 3)
                {
                    int ticks = Timer.TicksElapsed;

                    if (ticks - previousTicks < 50)
                    {
                        System.Threading.Thread.Sleep(50 + previousTicks - ticks);
                    }
                    else if (ticks - previousTicks > 100)
                    {
                        previousTicks = ticks - 100;
                    }

                    previousTicks += 50;

                    Video.WindowCaption = String.Format("{0} Time skew: {1}ms", WindowCaption, previousTicks - ticks);

                    frames = 0;
                }
            }

            AudioMixer.CloseMixer();
        }