public CachedXmlRpcClient getXMLRPCClient(string host, int port, string uri) { CachedXmlRpcClient c = null; lock (clients_mutex) { List <CachedXmlRpcClient> zombies = new List <CachedXmlRpcClient>(); foreach (CachedXmlRpcClient client in clients) { if (!client.in_use) { if (DateTime.Now.Subtract(client.last_use_time).TotalSeconds > 30 || client.dead) { zombies.Add(client); } else if (client.CheckIdentity(host, port, uri)) { c = client; break; } } } foreach (CachedXmlRpcClient C in zombies) { clients.Remove(C); C.Dispose(); } if (c == null) { c = new CachedXmlRpcClient(host, port, uri); clients.Add(c); } } c.AddRef(); return(c); }
public void releaseXMLRPCClient(CachedXmlRpcClient client) { client.DelRef(); client.Dispose(); }