private Client GetClient() { Client client; lock (FreeClients) { client = FreeClients.Any() ? FreeClients.Dequeue() : null; } if (client != null) { lock (UsingClients) { UsingClients.Add(client); } } return(client); }
public void FreeClient(Client client) { lock (UsingClients) { UsingClients.Remove(client); } lock (FreeClients) { FreeClients.Enqueue(client); } }