Table of Contents

Class RetryPolicy

Namespace
SapGui.Wrapper
Assembly
SapGui.Wrapper.dll

Configures and executes retry behaviour for SAP GUI operations.

Obtain an instance via WithRetry(int, int):

session.WithRetry(maxAttempts: 3, delayMs: 500).Run(() =>
{
    session.WaitReady();
    session.TextField("wnd[0]/usr/txtFoo").Text = "value";
});

Retries on SapComponentNotFoundException (slow screen loads) and TimeoutException (session still busy). Never retries on SapGuiNotFoundException — that is a fatal setup error.

public sealed class RetryPolicy
Inheritance
RetryPolicy
Inherited Members

Constructors

RetryPolicy(int, int)

Creates a retry policy with the given parameters.

public RetryPolicy(int maxAttempts = 3, int delayMs = 500)

Parameters

maxAttempts int

Maximum number of attempts. Must be ≥ 1.

delayMs int

Milliseconds to wait between attempts. Must be ≥ 0.

Properties

DelayMs

Delay between attempts in milliseconds (≥ 0). Default: 500.

public int DelayMs { get; }

Property Value

int

MaxAttempts

Maximum number of execution attempts (≥ 1). Default: 3.

public int MaxAttempts { get; }

Property Value

int

Methods

Run(Action)

Executes action up to MaxAttempts times, sleeping DelayMs ms between attempts.

public void Run(Action action)

Parameters

action Action

The operation to execute and potentially retry.

Exceptions

SapGuiNotFoundException

Always rethrown immediately — fatal setup error.

SapComponentNotFoundException

Thrown after all attempts are exhausted.

TimeoutException

Thrown after all attempts are exhausted.

Run<T>(Func<T>)

Executes func up to MaxAttempts times and returns its result.

public T Run<T>(Func<T> func)

Parameters

func Func<T>

The operation to execute and potentially retry.

Returns

T

The value returned by the first successful execution.

Type Parameters

T

Return type of the operation.

Exceptions

SapGuiNotFoundException

Always rethrown immediately — fatal setup error.

SapComponentNotFoundException

Thrown after all attempts are exhausted.

TimeoutException

Thrown after all attempts are exhausted.