/// <summary> /// Downloads the most recent copy of the endpoint address file and /// parses it to a collection of address range objects. /// </summary> public static AWSPublicIpAddressRanges Load(IWebProxy proxy) { const int maxDownloadRetries = 3; var retries = 0; while (retries < maxDownloadRetries) { try { var content = AWSSDKUtils.DownloadStringContent(IpAddressRangeEndpoint, proxy); AWSPublicIpAddressRanges instance = Parse(content); return(instance); } catch (Exception e) { retries++; if (retries == maxDownloadRetries) { throw new AmazonServiceException( string.Format(CultureInfo.InvariantCulture, "Error downloading public IP address ranges file from {0}.", IpAddressRangeEndpoint), e); } } var delay = (int)(Math.Pow(4, retries) * 100); delay = Math.Min(delay, 30 * 1000); AWSSDKUtils.Sleep(delay); } return(null); }
public static AWSPublicIpAddressRanges Load() { int num = 0; while (num < 3) { try { return(Parse(AWSSDKUtils.DownloadStringContent(IpAddressRangeEndpoint))); } catch (Exception innerException) { num++; if (num == 3) { throw new AmazonServiceException(string.Format(CultureInfo.InvariantCulture, "Error downloading public IP address ranges file from {0}.", IpAddressRangeEndpoint), innerException); } } AWSSDKUtils.Sleep(Math.Min((int)(Math.Pow(4.0, (double)num) * 100.0), 30000)); } return(null); }