/// <summary>Clean up the cache if necessary and close the context provided (if the flag indicates that processing was successful).</summary> /// <param name="retryPolicy">The retry policy.</param> /// <param name="context">The context.</param> /// <param name="state">The state.</param> /// <param name="succeeded">The succeeded.</param> protected void Close(IRetryPolicy retryPolicy, IRetryContext context, IRetryState state, bool succeeded) { if (state != null) { if (succeeded) { this.retryContextCache.Remove(state.GetKey()); retryPolicy.Close(context); } } else { retryPolicy.Close(context); } }
/// <summary>The close.</summary> /// <param name="context">The context.</param> public void Close(IRetryContext context) { // Only close those policies that have been used (opened): foreach (var policy in this.contexts.Keys) { policy.Close(this.GetContext(policy, context.GetParent())); } }