public async Task RunAsync(Func <Task> func) { ExponentialBackoff backoff = new ExponentialBackoff(this.maxRetries, this.delayMilliseconds, this.maxDelayMilliseconds); retry: try { await func(); } catch (Exception ex) when(ex is TimeoutException || ex is System.Net.Http.HttpRequestException || (ex is Microsoft.Azure.KeyVault.Models.KeyVaultErrorException && ((Microsoft.Azure.KeyVault.Models.KeyVaultErrorException)ex).Message.Contains("'429'")) ) { await backoff.Delay(); goto retry; } }
public async Task RunAsync(Func <Task> func) { ExponentialBackoff backoff = new ExponentialBackoff(this.maxRetries, this.delayMilliseconds, this.maxDelayMilliseconds); retry: try { await func(); } catch (Exception ex) when(ex is TimeoutException || ex is System.Net.Http.HttpRequestException) { Debug.WriteLine("Exception raised is: " + ex.GetType().ToString() + " –Message: " + ex.Message + " -- Inner Message: " + ex.InnerException.Message); await backoff.Delay(); goto retry; } }