public void asynSendMessageFromClient(MessageDescript descript, ClientInfo client, Action <ClientInfo, MessageDescript> allocToSendedMessage, Action <ClientInfo, Exception> allocToDropSendClient) { InfoSendRecvest info = new InfoSendRecvest(descript, client, allocToSendedMessage, allocToDropSendClient); sendRecvests.Enqueue(info); if (sendingNow) { return; } sendingNow = true; StartProtectedThread(SendingQueue); }
private void SendingQueue() { do { var info = new InfoSendRecvest(null, null, null, null); if (sendRecvests.TryDequeue(out info)) { SendMessage(info.Descript, info.Client, info.AllocToSendedMessage, info.AllocToDropSendClient); } else { return; } }while (sendRecvests.Count() != 0); sendingNow = false; }