private static void GameThread() { long num = 0L; GameMgr.m_clearGamesTimer = TickHelper.GetTickCount(); while (GameMgr.m_running) { long tickCount = TickHelper.GetTickCount(); try { GameMgr.UpdateGames(tickCount); GameMgr.ClearStoppedGames(tickCount); } catch (Exception exception) { GameMgr.log.Error("Room Mgr Thread Error:", exception); } long tickCount2 = TickHelper.GetTickCount(); num += GameMgr.THREAD_INTERVAL - (tickCount2 - tickCount); if (num > 0L) { Thread.Sleep((int)num); num = 0L; } else { if (num < -1000L) { GameMgr.log.WarnFormat("Room Mgr is delay {0} ms!", num); num += 1000L; } } } }
private static void GameThread() { long balance = 0L; GameMgr.m_clearGamesTimer = TickHelper.GetTickCount(); while (GameMgr.m_running) { long start = TickHelper.GetTickCount(); try { GameMgr.UpdateGames(start); GameMgr.ClearStoppedGames(start); } catch (Exception ex) { GameMgr.log.Error("Room Mgr Thread Error:", ex); } long end = TickHelper.GetTickCount(); balance += GameMgr.THREAD_INTERVAL - (end - start); if (balance > 0L) { Thread.Sleep((int)balance); balance = 0L; } else { if (balance < -1000L) { GameMgr.log.WarnFormat("Room Mgr is delay {0} ms!", balance); balance += 1000L; } } if (GameMgr.DELAY_TIME > 0) { GameMgr.log.ErrorFormat("Delay for {0} ms!", GameMgr.DELAY_TIME); Thread.Sleep(GameMgr.DELAY_TIME); } } }