Table of Contents

Interface ISyncPolicy<TResult>

Namespace
Polly
Assembly
Polly.dll

An interface defining all executions available on a synchronous policy generic-typed for executions returning results of type TResult.

public interface ISyncPolicy<TResult> : IsPolicy

Type Parameters

TResult

The type of the result of funcs executed through the Policy.

Inherited Members

Methods

Execute(Func<Context, CancellationToken, TResult>, Context, CancellationToken)

Executes the specified action within the policy and returns the result.

TResult Execute(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)

Parameters

action Func<Context, CancellationToken, TResult>

The action to perform.

context Context

Context data that is passed to the exception policy.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The value returned by the action

Execute(Func<Context, CancellationToken, TResult>, IDictionary<string, object>, CancellationToken)

Executes the specified action within the policy and returns the result.

TResult Execute(Func<Context, CancellationToken, TResult> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)

Parameters

action Func<Context, CancellationToken, TResult>

The action to perform.

contextData IDictionary<string, object>

Arbitrary data that is passed to the exception policy.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The value returned by the action

Exceptions

ArgumentNullException

contextData

Execute(Func<Context, TResult>, Context)

Executes the specified action within the policy and returns the result.

TResult Execute(Func<Context, TResult> action, Context context)

Parameters

action Func<Context, TResult>

The action to perform.

context Context

Context data that is passed to the exception policy.

Returns

TResult

The value returned by the action

Exceptions

ArgumentNullException

context

ArgumentNullException

contextData

Execute(Func<Context, TResult>, IDictionary<string, object>)

Executes the specified action within the policy and returns the result.

TResult Execute(Func<Context, TResult> action, IDictionary<string, object> contextData)

Parameters

action Func<Context, TResult>

The action to perform.

contextData IDictionary<string, object>

Arbitrary data that is passed to the exception policy.

Returns

TResult

The value returned by the action

Exceptions

ArgumentNullException

contextData

ArgumentNullException

contextData

Execute(Func<CancellationToken, TResult>, CancellationToken)

Executes the specified action within the policy and returns the result.

TResult Execute(Func<CancellationToken, TResult> action, CancellationToken cancellationToken)

Parameters

action Func<CancellationToken, TResult>

The action to perform.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The value returned by the action

Execute(Func<TResult>)

Executes the specified action within the policy and returns the Result.

TResult Execute(Func<TResult> action)

Parameters

action Func<TResult>

The action to perform.

Returns

TResult

The value returned by the action

ExecuteAndCapture(Func<Context, CancellationToken, TResult>, Context, CancellationToken)

Executes the specified action within the policy and returns the captured result.

PolicyResult<TResult> ExecuteAndCapture(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)

Parameters

action Func<Context, CancellationToken, TResult>

The action to perform.

context Context

Context data that is passed to the exception policy.

cancellationToken CancellationToken

The cancellation token.

Returns

PolicyResult<TResult>

The captured result

ExecuteAndCapture(Func<Context, CancellationToken, TResult>, IDictionary<string, object>, CancellationToken)

Executes the specified action within the policy and returns the captured result.

PolicyResult<TResult> ExecuteAndCapture(Func<Context, CancellationToken, TResult> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)

Parameters

action Func<Context, CancellationToken, TResult>

The action to perform.

contextData IDictionary<string, object>

Arbitrary data that is passed to the exception policy.

cancellationToken CancellationToken

The cancellation token.

Returns

PolicyResult<TResult>

The captured result

Exceptions

ArgumentNullException

contextData

ExecuteAndCapture(Func<Context, TResult>, Context)

Executes the specified action within the policy and returns the captured result.

PolicyResult<TResult> ExecuteAndCapture(Func<Context, TResult> action, Context context)

Parameters

action Func<Context, TResult>

The action to perform.

context Context

Context data that is passed to the exception policy.

Returns

PolicyResult<TResult>

The captured result

Exceptions

ArgumentNullException

contextData

ExecuteAndCapture(Func<Context, TResult>, IDictionary<string, object>)

Executes the specified action within the policy and returns the captured result.

PolicyResult<TResult> ExecuteAndCapture(Func<Context, TResult> action, IDictionary<string, object> contextData)

Parameters

action Func<Context, TResult>

The action to perform.

contextData IDictionary<string, object>

Arbitrary data that is passed to the exception policy.

Returns

PolicyResult<TResult>

The captured result

Exceptions

ArgumentNullException

contextData

ExecuteAndCapture(Func<CancellationToken, TResult>, CancellationToken)

Executes the specified action within the policy and returns the captured result

PolicyResult<TResult> ExecuteAndCapture(Func<CancellationToken, TResult> action, CancellationToken cancellationToken)

Parameters

action Func<CancellationToken, TResult>

The action to perform.

cancellationToken CancellationToken

The cancellation token.

Returns

PolicyResult<TResult>

The captured result

ExecuteAndCapture(Func<TResult>)

Executes the specified action within the policy and returns the captured result

PolicyResult<TResult> ExecuteAndCapture(Func<TResult> action)

Parameters

action Func<TResult>

The action to perform.

Returns

PolicyResult<TResult>

The captured result

WithPolicyKey(string)

Sets the PolicyKey for this Policy instance. Must be called before the policy is first used. Can only be set once.

ISyncPolicy<TResult> WithPolicyKey(string policyKey)

Parameters

policyKey string

The unique, used-definable key to assign to this Policy instance.

Returns

ISyncPolicy<TResult>