Show / Hide Table of Contents

Class Polling

Helper methods for polling scenarios.

Inheritance
System.Object
Polling
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Api.Gax
Assembly: Google.Api.Gax.dll
Syntax
public static class Polling

Methods

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

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

Declaration
public static TResponse PollRepeatedly<TResponse>(Func<DateTime? , TResponse> pollAction, Predicate<TResponse> completionPredicate, IClock clock, IScheduler scheduler, PollSettings pollSettings, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Func<System.Nullable<System.DateTime>, TResponse> pollAction

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.

System.Predicate<TResponse> completionPredicate

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

IClock clock

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

IScheduler scheduler

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

PollSettings pollSettings

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

System.Threading.CancellationToken cancellationToken

The cancellation token used to cancel delays, if any.

Returns
Type Description
TResponse

The completed response.

Type Parameters
Name Description
TResponse

The response type.

Exceptions
Type Condition
System.TimeoutException

The timeout specified in the poll settings expired.

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

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

Declaration
public static Task<TResponse> PollRepeatedlyAsync<TResponse>(Func<DateTime? , Task<TResponse>> pollAction, Predicate<TResponse> completionPredicate, IClock clock, IScheduler scheduler, PollSettings pollSettings, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Func<System.Nullable<System.DateTime>, System.Threading.Tasks.Task<TResponse>> pollAction

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.

System.Predicate<TResponse> completionPredicate

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

IClock clock

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

IScheduler scheduler

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

PollSettings pollSettings

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

System.Threading.CancellationToken cancellationToken

The cancellation token used to cancel delays, if any.

Returns
Type Description
System.Threading.Tasks.Task<TResponse>

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

Type Parameters
Name Description
TResponse

The response type.

Back to top