Пример #1
0
        /// <summary>
        /// Creates a new application of the given type and inits engine then.
        /// This method returns after the application stopped (CurrentApplication.IsRunning is false) and the engine was shut down.
        /// There can always be only one active application.
        /// </summary>
        static public void RunApplication <T>() where T : IApplication, new()
        {
            Assert.Always(CurrentApplication == null, "There is already an activate application.");

            using (new ScopedLogGroup("Application Creation"))
            {
                CurrentApplication = new T();
            }

            using (new ScopedLogGroup("Engine Init"))
            {
                // Todo: Engine init.
            }

            CurrentApplication.AfterEngineInit();

            Log.Log.Info("Starting application run.");
            CurrentApplication.Run();
            Log.Log.Info("Application run finished.");

            CurrentApplication.BeforeEngineShutdown();

            using (new ScopedLogGroup("Engine Shutdown"))
            {
                // Todo: Engine shutdown.
            }

            CurrentApplication.AfterEngineShutdown();
            CurrentApplication = null;
        }