private void ClearAndFailChannelQueuedMessages(ErrorInfo error) { lock (_lockQueue) { foreach (var messageAndCallback in QueuedMessages) { messageAndCallback.SafeExecute(false, error); } QueuedMessages.Clear(); } }
private int SendQueuedMessages() { List <MessageAndCallback> list; lock (_lockQueue) { if (QueuedMessages.Count <= 0) { return(0); } // Swap the list. list = new List <MessageAndCallback>(QueuedMessages); QueuedMessages.Clear(); } foreach (var qpm in list) { SendMessage(qpm.Message, qpm.Callback); } return(list.Count); }