Overview

When you define a Polly exception-handling policy, the policy will internally catch matched exceptions and handle them as the policy defines: orchestrate a retry; update circuit-breaker statistics; or channel execution to a fallback.

Debugging such executions can however be noisy in Visual Studio: commonly-used settings cause Visual Studio to

TL;DR Sync-over-async and async-over-sync implementations are both to be avoided. Users expect policy hooks on async policies to be async methods (and vice versa for sync), and thus a single Policy instance

Background

Polly offers both non-generic policies Policy with a generic .Execute<TResult>(...)method, as well as generic policies Policy<TResult>. This article sets out to answer questions Polly users sometimes raise: Why do both exist? And why can't I just use the generic .Execute<TResult&

TL;DR In Polly V5.1.0, we've extended Context so that it can be used to pass information between different parts of an execution through a policy. Featured Use Cases include honouring RetryAfter headers, and re-establishing authentication automatically.