private RemoteNode AddClient(Func <RemoteNode> fn) { RemoteNode client = null; try { client = fn(); _clients.Add(client); return(client); } catch (Exception) { if (client != null) { client.Dispose(); _clients.Remove(client); } throw; } }
public INode ConnectTo(IPEndPoint ep) { return(AddClient(() => RemoteNode.Create(_operationTracker, ep))); }
public RemoteNode ConnectTo(string address, TimeSpan connectTimeout) { return(AddClient(() => RemoteNode.Create(_operationTracker, address, connectTimeout))); }