AsyncExecutorWithRetries.ExecuteWithRetries 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
ExecuteWithRetries(Func<Int32,Task>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)
根據重試組態參數執行指定函式的次數。
public static System.Threading.Tasks.Task ExecuteWithRetries (Func<int,System.Threading.Tasks.Task> action, int maxNumErrorTries, Func<Exception,int,bool> retryExceptionFilter, TimeSpan maxExecutionTime, Orleans.Internal.IBackoffProvider onErrorBackOff);
static member ExecuteWithRetries : Func<int, System.Threading.Tasks.Task> * int * Func<Exception, int, bool> * TimeSpan * Orleans.Internal.IBackoffProvider -> System.Threading.Tasks.Task
Public Shared Function ExecuteWithRetries (action As Func(Of Integer, Task), maxNumErrorTries As Integer, retryExceptionFilter As Func(Of Exception, Integer, Boolean), maxExecutionTime As TimeSpan, onErrorBackOff As IBackoffProvider) As Task
參數
- maxNumErrorTries
- Int32
重試次數上限。
- maxExecutionTime
- TimeSpan
最大執行時間。
- onErrorBackOff
- IBackoffProvider
輪詢提供者。
傳回
, Task 表示作業。
適用於
ExecuteWithRetries<T>(Func<Int32,Task<T>>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)
根據重試組態參數執行指定函式的次數。
public static System.Threading.Tasks.Task<T> ExecuteWithRetries<T> (Func<int,System.Threading.Tasks.Task<T>> function, int maxNumErrorTries, Func<Exception,int,bool> retryExceptionFilter, TimeSpan maxExecutionTime, Orleans.Internal.IBackoffProvider onErrorBackOff);
static member ExecuteWithRetries : Func<int, System.Threading.Tasks.Task<'T>> * int * Func<Exception, int, bool> * TimeSpan * Orleans.Internal.IBackoffProvider -> System.Threading.Tasks.Task<'T>
Public Shared Function ExecuteWithRetries(Of T) (function As Func(Of Integer, Task(Of T)), maxNumErrorTries As Integer, retryExceptionFilter As Func(Of Exception, Integer, Boolean), maxExecutionTime As TimeSpan, onErrorBackOff As IBackoffProvider) As Task(Of T)
類型參數
- T
參數
- maxNumErrorTries
- Int32
重試次數上限。
- maxExecutionTime
- TimeSpan
最大執行時間。
- onErrorBackOff
- IBackoffProvider
輪詢提供者。
傳回
從所提供函式成功調用傳回的值。
適用於
ExecuteWithRetries<T>(Func<Int32,Task<T>>, Int32, Int32, Func<T, Int32,Boolean>, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider, IBackoffProvider)
根據重試組態參數,執行指定的 function
次數。
public static System.Threading.Tasks.Task<T> ExecuteWithRetries<T> (Func<int,System.Threading.Tasks.Task<T>> function, int maxNumSuccessTries, int maxNumErrorTries, Func<T,int,bool> retryValueFilter, Func<Exception,int,bool> retryExceptionFilter, TimeSpan maxExecutionTime = default, Orleans.Internal.IBackoffProvider onSuccessBackOff = default, Orleans.Internal.IBackoffProvider onErrorBackOff = default);
static member ExecuteWithRetries : Func<int, System.Threading.Tasks.Task<'T>> * int * int * Func<'T, int, bool> * Func<Exception, int, bool> * TimeSpan * Orleans.Internal.IBackoffProvider * Orleans.Internal.IBackoffProvider -> System.Threading.Tasks.Task<'T>
Public Shared Function ExecuteWithRetries(Of T) (function As Func(Of Integer, Task(Of T)), maxNumSuccessTries As Integer, maxNumErrorTries As Integer, retryValueFilter As Func(Of T, Integer, Boolean), retryExceptionFilter As Func(Of Exception, Integer, Boolean), Optional maxExecutionTime As TimeSpan = Nothing, Optional onSuccessBackOff As IBackoffProvider = Nothing, Optional onErrorBackOff As IBackoffProvider = Nothing) As Task(Of T)
類型參數
- T
的基礎傳回型 function
別。
參數
- maxNumSuccessTries
- Int32
成功執行嘗試的最大數目。
ExecuteWithRetries(Func<Int32,Task>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)如果由 retryValueFilter
指示,則會嘗試重新執行指定的 function
。
設定為 -1
,直到滿足為止, retryValueFilter
以取得無限制的成功重試次數。 僅針對一次成功嘗試設定為 0
,這會導致 retryValueFilter
忽略,而且指定的 function
只會執行一次,直到第一次成功為止。
- maxNumErrorTries
- Int32
因錯誤而嘗試執行的最大次數。 針對不限數目的錯誤重試,設定為 -1,直到 retryExceptionFilter
滿足為止。
- maxExecutionTime
- TimeSpan
函式的最大 ExecuteWithRetries(Func<Int32,Task>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider) 執行時間。
- onSuccessBackOff
- IBackoffProvider
輪詢提供者物件,決定成功重試之間要等候多少。
- onErrorBackOff
- IBackoffProvider
輪詢提供者物件,決定在錯誤重試之間等候多少
傳回
從 成功叫用 function
傳回的值。