public static Task <bool> PerformServerActionAsync(string server, Action action) { var proxies = HAProxyGroup.GetAllProxies(); var pairs = proxies .SelectMany(p => p.Servers .Where(s => s.Name == server) .Select(s => new ActionPair { Proxy = p, Server = s }) ).ToList(); return(PostActionsAsync(pairs, action)); }
public static bool PerformServerAction(string server, Action action) { var proxies = HAProxyGroup.GetAllProxies(); var matchingServers = proxies.SelectMany(p => p.Servers.Where(s => s.Name == server).Select(s => new { Proxy = p, Server = s })); var result = true; Parallel.ForEach(matchingServers, _parallelOptions, pair => { result = result && PostAction(pair.Proxy, pair.Server, action); }); return(result); }