//--------------------------------------------------------------------- void _threadLogic() { float elapsed_tm = 0; while (!mSignDestroy) { mStopwatch.Restart(); //更新zk ZkClient.update(); // session连接,断开通知 SessionEvent se; while (!mQueSessionEvent.IsEmpty) { if (mQueSessionEvent.TryDequeue(out se)) { onSessionEvent(ref se); } } // 每帧更新 _update(elapsed_tm); mStopwatch.Stop(); float watch_time = mStopwatch.ElapsedMilliseconds; if (watch_time > mTimeLogicGap) { elapsed_tm = watch_time / 1000.0f; } else { Thread.Sleep((int)(mTimeLogicGap - watch_time)); elapsed_tm = mTimeLogicGap / 1000.0f; } } }