static async Task enterGameLoop() { await HotfixMgr.ReloadModule("");//启动游戏[hotfix工程实现一个IHotfix接口] Settings.Ins.StartServerTime = DateTime.Now; Console.WriteLine("enter game loop"); LOGGER.Info("enter game loop"); int gcTime = 0; Settings.Ins.AppRunning = true; while (Settings.Ins.AppRunning) { gcTime += 1; if (gcTime > 1000)//定时gc一下 { gcTime = 0; GC.Collect(); } await Task.Delay(TimeSpan.FromSeconds(1)); } Console.WriteLine("exit game loop 开服时长:" + (DateTime.Now - Settings.Ins.StartServerTime)); LOGGER.Info("exit game loop 开服时长:" + (DateTime.Now - Settings.Ins.StartServerTime)); await HotfixMgr.Stop();//退出游戏 Console.WriteLine("exit game loop succeed"); LOGGER.Info("exit game loop succeed"); }
static async Task enterGameLoop() { await HotfixMgr.ReloadModule("");//启动游戏[hotfix工程实现一个IHotfix接口] Settings.Ins.StartServerTime = DateTime.Now; Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("enter game loop 使用[ctrl+C]退出程序,不要强退,否则无法回存State"); Console.WriteLine("压力测试请将server_config.json中IsDebug改为false"); Console.ForegroundColor = ConsoleColor.Gray; LOGGER.Info("enter game loop"); int gcTime = 0; Settings.Ins.AppRunning = true; while (Settings.Ins.AppRunning) { gcTime += 1; if (gcTime > 1000)//定时gc一下 { gcTime = 0; GC.Collect(); } await Task.Delay(TimeSpan.FromSeconds(1)); } Console.WriteLine("exit game loop 开服时长:" + (DateTime.Now - Settings.Ins.StartServerTime)); LOGGER.Info("exit game loop 开服时长:" + (DateTime.Now - Settings.Ins.StartServerTime)); await HotfixMgr.Stop();//退出游戏 Console.WriteLine("exit game loop succeed"); LOGGER.Info("exit game loop succeed"); }