private static void RoomThread() { Thread.CurrentThread.Priority = ThreadPriority.Highest; long balance = 0L; RoomMgr.m_clearTick = TickHelper.GetTickCount(); while (RoomMgr.m_running) { long start = TickHelper.GetTickCount(); int count = 0; try { count = RoomMgr.ExecuteActions(); if (RoomMgr.m_clearTick <= start) { RoomMgr.m_clearTick += (long)RoomMgr.CLEAR_ROOM_INTERVAL; RoomMgr.ClearRooms(start); } } catch (Exception ex) { RoomMgr.log.Error("Room Mgr Thread Error:", ex); } long end = TickHelper.GetTickCount(); balance += (long)RoomMgr.THREAD_INTERVAL - (end - start); if (end - start > (long)(RoomMgr.THREAD_INTERVAL * 2)) { RoomMgr.log.WarnFormat("Room Mgr is spent too much times: {0} ms,count:{1}", end - start, count); } if (balance > 0L) { Thread.Sleep((int)balance); balance = 0L; } else { if (balance < -1000L) { balance += 1000L; } } if (RoomMgr.DELAY_TIME > 0) { RoomMgr.log.ErrorFormat("Delay for {0} ms!", RoomMgr.DELAY_TIME); Thread.Sleep(RoomMgr.DELAY_TIME); } } }
private static void RoomThread() { Thread.CurrentThread.Priority = ThreadPriority.Highest; long num = 0L; RoomMgr.m_clearTick = TickHelper.GetTickCount(); while (RoomMgr.m_running) { long tickCount = TickHelper.GetTickCount(); int num2 = 0; try { num2 = RoomMgr.ExecuteActions(); if (RoomMgr.m_clearTick <= tickCount) { RoomMgr.m_clearTick += (long)RoomMgr.CLEAR_ROOM_INTERVAL; RoomMgr.ClearRooms(tickCount); } } catch (Exception exception) { RoomMgr.log.Error("Room Mgr Thread Error:", exception); } long tickCount2 = TickHelper.GetTickCount(); num += (long)RoomMgr.THREAD_INTERVAL - (tickCount2 - tickCount); if (tickCount2 - tickCount > (long)(RoomMgr.THREAD_INTERVAL * 2)) { RoomMgr.log.WarnFormat("Room Mgr is spent too much times: {0} ms,count:{1}", tickCount2 - tickCount, num2); } if (num > 0L) { Thread.Sleep((int)num); num = 0L; } else { if (num < -1000L) { num += 1000L; } } } }