Table of Contents

Class Awaiter

Namespace
Cuemon.Threading
Assembly
Cuemon.Core.dll

Provides a set of static methods for awaiting asynchronous operations.

public static class Awaiter
Inheritance
Awaiter

Methods

RunUntilSuccessfulOrTimeoutAsync(Func<Task<ConditionalValue>>, Action<AsyncRunOptions>)

Repeatedly invokes the specified asynchronous method until it succeeds or the configured Timeout is reached.

public static Task<ConditionalValue> RunUntilSuccessfulOrTimeoutAsync(Func<Task<ConditionalValue>> method, Action<AsyncRunOptions> setup = null)

Parameters

method Func<Task<ConditionalValue>>

The asynchronous function delegate to execute, returning a ConditionalValue indicating success or failure.

setup Action<AsyncRunOptions>

The AsyncRunOptions which may be configured.

Returns

Task<ConditionalValue>

A task that represents the asynchronous operation. The task result contains the ConditionalValue returned by the last invocation of method, or an unsuccessful value if the timeout is reached.

Remarks

The method is invoked repeatedly with a delay specified by Delay until it returns a successful ConditionalValue or the timeout specified by Timeout is reached.
Potential exceptions thrown by method are caught and collected. If the operation does not succeed before the timeout, UnsuccessfulValue will be conditionally initialized:
1: No caught exceptions; initialized with default constructor,
2: One caught exception; initialized with caught exception,
3: Two or more exceptions; initialized with AggregateException containing all exceptions.