private void HandleMessages(int maxCount) { try { for (int i = 0; i < maxCount; ++i) { if (m_MsgQueue.Count > 0) { NodeMessageInfo info = null; m_MsgQueue.TryDequeue(out info); if (null != info) { try { NodeMessageDispatcher.HandleNodeMessage(info.Seq, info.SourceHandle, info.DestHandle, info.Data); m_MsgPool.Enqueue(info); } catch (Exception ex) { LogSys.Log(LOG_TYPE.ERROR, "NodeMessageThread NodeMessageDispatcher.HandleNodeMessage() throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } } } else { break; } } } catch (Exception ex) { LogSys.Log(LOG_TYPE.ERROR, "NodeMessageThread.HandleMessages throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
internal void QueueMessage(uint seq, int sourceHandle, int destHandle, byte[] data) { try { NodeMessageInfo info; if (!m_MsgPool.TryDequeue(out info)) { info = new NodeMessageInfo(); } info.Seq = seq; info.SourceHandle = sourceHandle; info.DestHandle = destHandle; info.Data = data; m_MsgQueue.Enqueue(info); } catch (Exception ex) { LogSys.Log(LOG_TYPE.ERROR, "NodeMessageThread.QueueMessage {0} {1} {2} throw exception:{3}\n{4}", seq, sourceHandle, destHandle, ex.Message, ex.StackTrace); } }