private void Initialize(TransactionDelegate transactionDelegate, RetryDelegate retryDelegate, TransactionOptions options) { _options = options; State = TransactionState.Active; TransactionDelegate = transactionDelegate; RetryDelegate = retryDelegate; }
public static bool Retry(RetryDelegate del, int numberOfRetries, int msPause) { int counter = 0; RetryLabel: try { counter++; del.Invoke(); return(true); } catch (Exception ex) { if (counter > numberOfRetries) { throw ex; } else { if (msPause > 0) { Thread.Sleep(msPause); } goto RetryLabel; } } }
public BCRetryData(RetryDelegate in_delegate, object in_retryData, SuccessCallback in_success = null, FailureCallback in_failure = null) { retryDelegate = in_delegate; retryData = in_retryData; success = in_success; failure = in_failure; }
public abstract Task <TResult> DeleteAsync <TData, TResult>(TData document, Func <TResult> success, Func <TResult> onNotFound, Func <ExtendedErrorInformationCodes, string, TResult> onFailure = default(Func <ExtendedErrorInformationCodes, string, TResult>), RetryDelegate onTimeout = default(RetryDelegate)) where TData : class, ITableEntity;
public static T Times <T>(RetryDelegate <T> del, int numberOfRetries, int msPause, bool throwExceptions) { int counter = 0; BeginLabel: try { counter++; return(del.Invoke()); } catch (Exception ex) { if (counter > numberOfRetries) { if (throwExceptions) { throw; } else { return(default(T)); } } else { if (RetryDelegateFailed != null) { RetryDelegateFailed(ex, counter); } Thread.Sleep(msPause); goto BeginLabel; } } }
/// <summary> /// Retry delegate. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="del"></param> /// <param name="numberOfRetries"></param> /// <param name="msPause"></param> /// <returns></returns> public static T Retry <T>(RetryDelegate <T> del, int numberOfRetries, int msPause) { var counter = 0; RetryLabel: try { counter++; return(del.Invoke()); } catch (Exception ex) { if (counter > numberOfRetries) { throw; } if (msPause > 0) { Thread.Sleep(msPause); } goto RetryLabel; } }
public abstract Task <TResult> UpdateIfNotModifiedAsync <TData, TResult>(TData data, Func <TResult> success, Func <TResult> documentModified, Func <ExtendedErrorInformationCodes, string, TResult> onFailure = default(Func <ExtendedErrorInformationCodes, string, TResult>), RetryDelegate onTimeout = default(RetryDelegate)) where TData : ITableEntity;
public abstract Task <TResult> CreateAsync <TResult, TDocument>(string rowKey, string partitionKey, TDocument document, Func <TResult> onSuccess, Func <TResult> onAlreadyExists, Func <ExtendedErrorInformationCodes, string, TResult> onFailure = default(Func <ExtendedErrorInformationCodes, string, TResult>), RetryDelegate onTimeout = default(RetryDelegate)) where TDocument : class, ITableEntity;
public abstract Task <TResult> FindByIdAsync <TEntity, TResult>( string rowKey, string partitionKey, Func <TEntity, TResult> onSuccess, Func <TResult> onNotFound, Func <ExtendedErrorInformationCodes, string, TResult> onFailure = default(Func <ExtendedErrorInformationCodes, string, TResult>), RetryDelegate onTimeout = default(RetryDelegate)) where TEntity : class, ITableEntity;
public static T Retry <T>(RetryDelegate <T> Action, CompletedDelegate <T, Object> Completed, Object completed_delegate_object, int wait_secs, int max_tries, TimeSpan timeout_secs) { T result = default(T); DateTime start = DateTime.UtcNow; int tries = 0; var method_name = Action.Method.Name; while (TimeToGiveUp(start, timeout_secs, tries, max_tries) == false) { try { tries++; result = Action.Invoke(); if (Completed(result, completed_delegate_object) == true) { return(result); } } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "RetryDelegate: " + method_name, e.Message + e.StackTrace); throw (e); } HttpUtils.Wait(wait_secs); } if (TimedOut(start, timeout_secs)) { throw RetryTimedOut; } if (ExceededTries(tries, max_tries)) { throw RetryExceededMaxTries; } return(result); // default(T) }
// Retry delegate with default retry settings. public static T Retry <T>(RetryDelegate <T> del) { return(Retry <T>(del, retryCount, retryIntervalMS)); }
// Retry delegate with default retry settings. public static bool Retry(RetryDelegate del) { return(Retry(del, retryCount, retryIntervalMS)); }
public static Transaction ExecuteTransaction(TransactionDelegate transactionDelegate, RetryDelegate retryDelegate, TransactionOptions options) { _trasaction = new Transaction(transactionDelegate, retryDelegate); _trasaction.TransactionDelegate.Invoke(_trasaction); while (_trasaction.State == TransactionState.Aborted && _trasaction.RetryDelegate != null && _trasaction.RetryDelegate.Invoke(_trasaction)) { _trasaction.TransactionDelegate.Invoke(_trasaction); } return(_trasaction); }
internal Transaction(TransactionDelegate transactionDelegate, RetryDelegate retryDelegate) { Initialize(transactionDelegate, retryDelegate, new TransactionOptions()); }
internal Transaction(TransactionDelegate transactionDelegate, RetryDelegate retryDelegate, TransactionOptions options) { Initialize(transactionDelegate, retryDelegate, options); }
private void reTry(RetryDelegate retryAction) { if (this.sleeping) { this.sleeping = false; retryAction.DynamicInvoke(new object[0]); } else { this.sleeping = true; SA_StorageWorker bw_NewWorker = new SA_StorageWorker(this); bw_NewWorker.DoWork += new DoWorkEventHandler(this.bw_Sleep_DoWork); this.SetCurrentWorker(bw_NewWorker); } }
public static Transaction ExecuteTransaction(TransactionDelegate transactionDelegate, RetryDelegate retryDelegate) { return(ExecuteTransaction(transactionDelegate, retryDelegate, new TransactionOptions())); }
public RetryPolicy(RetryDelegate shouldRetryAfter = null) { this.shouldRetryAfter = shouldRetryAfter ?? Default; }
// Retry delegate with default retry settings. public static T Retry <T>(RetryDelegate <T> del, int numberOfRetries) { return(Retry <T>(del, numberOfRetries, RetryIntervalMs)); }