public List <QueueMember> selectQueue(QueueInfo queue) { try { // Reset values if (queue.AllQueueMembers == null) { queue.AllQueueMembers = new List <QueueMember>(); } else { queue.AllQueueMembers.Clear(); } currentQueueMembers.Clear(); var pageNumber = 1; var pageCount = 1; do { var allQueueMemberEntityListing = routingApi.GetRoutingQueueUsers(queue.Id, 100, pageNumber++, "name"); pageCount = allQueueMemberEntityListing.PageCount.Value; queue.AllQueueMembers.AddRange(allQueueMemberEntityListing.Entities); } while (pageNumber <= pageCount); var queueMemberEntityListing = new QueueMemberEntityListing(); pageNumber = 1; pageCount = 1; do { queueMemberEntityListing = routingApi.GetRoutingQueueUsers(queue.Id, 100, pageNumber++, "name", null); pageCount = queueMemberEntityListing.PageCount.Value; currentQueueMembers.AddRange(queueMemberEntityListing.Entities); } while (pageNumber <= pageCount); } catch (Exception ex) { AddLog($"Error in cmbQueues_SelectedIndexChanged: {ex}"); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(currentQueueMembers); }