Table of Contents

Class ResilienceContext

Namespace
Polly
Assembly
Polly.Core.dll

A context assigned to a single execution of ResiliencePipeline. It is created manually or automatically when the user calls the various extensions on top of ResiliencePipeline. After every execution the context should be discarded and returned to the pool.

public sealed class ResilienceContext
Inheritance
ResilienceContext
Inherited Members

Remarks

Do not re-use an instance of ResilienceContext across more than one execution. The ResilienceContext is retrieved from the pool by calling the Get(CancellationToken) method. After you are done with it you should return it to the pool by calling the Return(ResilienceContext) method.

Properties

CancellationToken

Gets the CancellationToken associated with the execution.

public CancellationToken CancellationToken { get; }

Property Value

CancellationToken

ContinueOnCapturedContext

Gets a value indicating whether the execution should continue on the captured context.

public bool ContinueOnCapturedContext { get; }

Property Value

bool

OperationKey

Gets a key unique to the call site of the current execution.

public string? OperationKey { get; }

Property Value

string

The default value is null.

Remarks

Resilience context instances are commonly reused across multiple call sites. Set an OperationKey so that logging and metrics can distinguish usages of policy instances at different call sites. The operation key value should have a low cardinality (i.e. do not assign values such as Guid to this property).

Properties

Gets the custom properties attached to the context.

public ResilienceProperties Properties { get; }

Property Value

ResilienceProperties