private void CheckMsgID(string ID) { if (TempMsg.ID == ID) { TempMsg = null; } }
private void CreateMsgQueueSend() { SendMsgThread = new Thread(() => { int SendTime = 0; while (TcpSocketServer.TcpLifeCycle != TcpSocketServer.NetWorkLife.Destory) { try { if (TempMsg == null) { if (SendMsgQueue != null) { if (SendMsgQueue.Count > 0) { TempMsg = SendMsgQueue.Dequeue(); //开始发送消息 SendMsg(TempMsg.Msg); SendTime = GetTimeStamp(); } } else { SendMsgQueue = new Queue <MsgParam>(); Debug.Log("SendMsgQueue 没有实例化 :" + SendMsgThread.Name); } } else { if (GetTimeStamp() - SendTime >= MsgSendIntervalTime)//间隔一定时间补发消息 { //开始发送消息 SendMsg(TempMsg.Msg); SendTime = GetTimeStamp(); } } Thread.Sleep(200); } catch (ThreadAbortException ex) { Debug.Log("消息发送队列线程关闭"); } catch (Exception ex) { Debug.Log("CreateMsgQueueSend" + ex.Message); } } Debug.Log("消息发送队列线程正常退出"); }); SendMsgThread.IsBackground = true; SendMsgThread.Start(); }