Class Polling (4.0.0)

public static class Polling

Helper methods for polling scenarios.

Inheritance

Object > Polling

Namespace

Google.Api.Gax

Assembly

Google.Api.Gax.dll

Methods

PollRepeatedly<TResponse>(Func<Nullable<DateTime>, TResponse>, Predicate<TResponse>, IClock, IScheduler, PollSettings, CancellationToken)

public static TResponse PollRepeatedly<TResponse>(Func<DateTime?, TResponse> pollAction, Predicate<TResponse> completionPredicate, IClock clock, IScheduler scheduler, PollSettings pollSettings, CancellationToken cancellationToken)

Repeatedly calls the specified polling action, delaying between calls, until a given condition is met in the response.

Parameters
NameDescription
pollActionFunc<Nullable<DateTime>, TResponse>

The poll action, typically performing an RPC. The value passed to the action is the overall deadline, so that the RPC settings can be adjusted accordingly. A null value indicates no deadline.

completionPredicatePredicate<TResponse>

The test for whether to return the response (true) or continue polling (false). Must not be null.

clockIClock

The clock to use for determining deadlines. Must not be null.

schedulerIScheduler

The scheduler to use for delaying between calls. Must not be null.

pollSettingsPollSettings

The poll settings, controlling timeouts, call settings and delays.

cancellationTokenCancellationToken

The cancellation token used to cancel delays, if any.

Returns
TypeDescription
TResponse

The completed response.

Type Parameter
NameDescription
TResponse

The response type.

Exceptions
TypeDescription
TimeoutException

The timeout specified in the poll settings expired.

PollRepeatedlyAsync<TResponse>(Func<Nullable<DateTime>, Task<TResponse>>, Predicate<TResponse>, IClock, IScheduler, PollSettings, CancellationToken)

public static async Task<TResponse> PollRepeatedlyAsync<TResponse>(Func<DateTime?, Task<TResponse>> pollAction, Predicate<TResponse> completionPredicate, IClock clock, IScheduler scheduler, PollSettings pollSettings, CancellationToken cancellationToken)

Asynchronously repeatedly calls the specified polling action, delaying between calls, until a given condition is met in the response.

Parameters
NameDescription
pollActionFunc<Nullable<DateTime>, Task<TResponse>>

The poll action, typically performing an RPC. The value passed to the action is the overall deadline, so that the RPC settings can be adjusted accordingly. A null value indicates no deadline.

completionPredicatePredicate<TResponse>

The test for whether to return the response (true) or continue polling (false). Must not be null.

clockIClock

The clock to use for determining deadlines. Must not be null.

schedulerIScheduler

The scheduler to use for delaying between calls. Must not be null.

pollSettingsPollSettings

The poll settings, controlling timeouts, call settings and delays.

cancellationTokenCancellationToken

The cancellation token used to cancel delays, if any.

Returns
TypeDescription
Task<TResponse>

A task representing the asynchronous operation. The result of the task will be the completed response.

Type Parameter
NameDescription
TResponse

The response type.