public static void Run( ILauncher launcher, Node mainNode, IGameLooper gameLooper = null, Type gameTimeType = null ) { Launcher = launcher; MainNode = mainNode; if ( gameLooper == null ) GameLooper = new PlainGameLooper (); else GameLooper = gameLooper; int elapsedUpdateTimeStep = 0, elapsedDrawTimeStep = 0; int lastUpdateTimeStep = Environment.TickCount, lastDrawTimeStep = Environment.TickCount; GameTime updateGameTime, drawGameTime; if ( gameTimeType == null ) { updateGameTime = new GameTime (); drawGameTime = new GameTime (); } else { updateGameTime = Activator.CreateInstance ( gameTimeType ) as GameTime; drawGameTime = Activator.CreateInstance ( gameTimeType ) as GameTime; } thisThread = Thread.CurrentThread; launcher.Initialize (); Window.Show (); mainNode.Intro (); isRunningMode = true; GameLooper.Run ( () => { if ( AudioDevice != null ) AudioDevice.Update (); if ( elapsedUpdateTimeStep >= fixedUpdateTimeStep ) { updateGameTime.Update (); mainNode.Update ( updateGameTime ); elapsedUpdateTimeStep -= fixedUpdateTimeStep; } else { int temp = Environment.TickCount; elapsedUpdateTimeStep += ( temp - lastUpdateTimeStep ); lastUpdateTimeStep = temp; } }, () => { if ( invokedMethod.Count > 0 ) { foreach ( Action action in invokedMethod.ToArray () ) { action (); invokeSpinLock.Enter (); invokedMethod.Remove ( action ); invokeSpinLock.Exit (); } } if ( elapsedDrawTimeStep >= fixedDrawTimeStep ) { drawGameTime.Update (); mainNode.Draw ( drawGameTime ); elapsedDrawTimeStep -= fixedDrawTimeStep; } else { int temp = Environment.TickCount; elapsedDrawTimeStep += ( temp - lastDrawTimeStep ); lastDrawTimeStep = temp; } Window.DoEvents (); }, ref isRunningMode ); mainNode.Outro (); launcher.Dispose (); }