Posts

Showing posts with the label polly

Can I modify a Policy after it is built?

Can I modify a Policy after it is built? I'm creating an API method call which takes a Policy as an argument. However, in my method I'd like to 'add onto' this policy by including my own retry Action(s) so that I can perform intermediate logging and telemetry of my own. Similar in concept to adding Click events to a Windows UI control. Is there a way to modify a Policy after it's created? Or, is there a hook mechanism where I can define my own callbacks in the Execute method perhaps? Thanks -John 1 Answer 1 A Polly Policy is immutable; it cannot be modified after configuration. However, there are several ways in which you can attach extra behaviour to a policy. Policy There could be several approaches depending what you want to achieve. Note: All examples in this answer refer to synchronous policies / policy-hooks used when executing delegates synchronously, but all the same be...