Example #1
0
        void ServerMain(object arg)
        {
            EventWaitHandle serverStartWaitHandle = (EventWaitHandle)arg;

            Thread.CurrentThread.Priority = ThreadPriority.Lowest;
            Thread.CurrentThread.Name     = "SMain";

            if (m_save == Guid.Empty)
            {
                UpdateStatus("Creating Game");
                m_game = m_gameFactory.CreateGame(m_saveManager.GameDir, m_gameOptions);
                UpdateStatus("Game Created");
            }
            else
            {
                UpdateStatus("Loading Game");
                m_game = m_gameFactory.LoadGame(m_saveManager.GameDir, m_save);
                UpdateStatus("Game Loaded");
            }

            UpdateStatus("Starting Game");

            m_game.Run(serverStartWaitHandle);

            m_game = null;

            if (m_serverDomain != null)
            {
                AppDomain.Unload(m_serverDomain);
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }