//要执行的方法 private void ScanQueue() { while (ListQueue.Count > 0) { try { //从队列中取出 QueueInfo queueinfo = ListQueue.Dequeue(); //取出的queueinfo就可以用了,里面有你要的东西 //以下就是处理程序了 if (m_proc != null) { m_proc(queueinfo); Writelog(queueinfo); } } catch (Exception e) { LogHelper.WriteLog(typeof(Exception), e); //throw; } } }
public void AddQueue(string RecBuffer, IPEndPoint ip) //入列 { QueueInfo queueinfo = new QueueInfo(); queueinfo.m_RecBuffer = RecBuffer; queueinfo.m_ClientIp = ip.Address.ToString(); queueinfo.ClientIpPort = ip; ListQueue.Enqueue(queueinfo); }
private void Writelog(QueueInfo info) { string msg = ""; msg += info.ClientIpPort.ToString(); msg += " "; msg += info.m_RecBuffer; LogHelper.WriteLog(typeof(String), msg); }