如何在应用程序中更新备份 URL?比方说 Main URL 丢失了。备份url如何访问?
How to update backup URL in app? Lets say for example Main URL is missing. How the back up url will accesible?
如何在 Android 应用程序中更新备份 URL。假设 Main Url 丢失或无法访问 android 应用程序将如何切换到备份 URL?
你见过这个包裹吗Polly
Polly is a .NET 3.5 / 4.0 / 4.5 / PCL library that allows developers to express transient exception handling policies such as Retry, Retry Forever, Wait and Retry or Circuit Breaker in a fluent manner.
您可以用它来捕获 WebException
然后重试或关闭 URL。
下面是来自博客 post 的示例:
In this example, we will try connecting to our service five times, with an exponential wait of 2, 4, 8, 16, and 32 seconds between tries. This should give the device a chance to reestablish its network connection and continue the request to the api.
conferences = await Policy
.Handle<WebException>()
.WaitAndRetry
(
retryCount:5,
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
)
.ExecuteAsync(async () => await getConferencesTask);
这是一篇博客 post 谈论 Resilient network services with mobile Xamarin apps
如何在 Android 应用程序中更新备份 URL。假设 Main Url 丢失或无法访问 android 应用程序将如何切换到备份 URL?
你见过这个包裹吗Polly
Polly is a .NET 3.5 / 4.0 / 4.5 / PCL library that allows developers to express transient exception handling policies such as Retry, Retry Forever, Wait and Retry or Circuit Breaker in a fluent manner.
您可以用它来捕获 WebException
然后重试或关闭 URL。
下面是来自博客 post 的示例:
In this example, we will try connecting to our service five times, with an exponential wait of 2, 4, 8, 16, and 32 seconds between tries. This should give the device a chance to reestablish its network connection and continue the request to the api.
conferences = await Policy
.Handle<WebException>()
.WaitAndRetry
(
retryCount:5,
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
)
.ExecuteAsync(async () => await getConferencesTask);
这是一篇博客 post 谈论 Resilient network services with mobile Xamarin apps