public int DequeuAllReceivedMessages() { var dequeuCount = 0; try { while (receivedQueue.Count > 0) { var message = receivedQueue.Dequeue(); dequeuCount++; if (!callbackManager.InvokeCallback(message)) { if (MessageReceived.IsNull()) { MessageReceived(this, message); } } } } catch (Exception ex) { Unity.Console.DebugError("Client::DequeuAllReceivedMessages() Exception:", ex.Message); } return(dequeuCount); }