Table of Contents

Class AsyncRunOptions

Namespace
Cuemon.Threading
Assembly
Cuemon.Kernel.dll

Provides options that are related to asynchronous run operations.

public class AsyncRunOptions : AsyncOptions, IAsyncOptions, IParameterObject
Inheritance
AsyncRunOptions
Implements
Inherited Members

Examples

The following example demonstrates how to use to configure timeout and retry delay for an asynchronous operation.

using System;
using System.Threading;
using System.Threading.Tasks;
using Cuemon.Threading; // for AsyncRunOptions

namespace MyApp.Examples;

public class AsyncRunOptionsExample
{
    public async Task DemonstrateAsync()
    {
        var options = new AsyncRunOptions
        {
            Timeout = TimeSpan.FromSeconds(30),
            Delay = TimeSpan.FromMilliseconds(500)
        };
        Console.WriteLine(options.Timeout); // 00:00:30
        Console.WriteLine(options.Delay);   // 00:00:00.5000000

        // Use with cancellation support
        var withCancellation = new AsyncRunOptions
        {
            Timeout = TimeSpan.FromSeconds(10),
            CancellationToken = new CancellationTokenSource(5000).Token
        };

        // Defaults: timeout 5s, delay 100ms
        var defaults = new AsyncRunOptions();
        Console.WriteLine(defaults.Timeout); // 00:00:05
        Console.WriteLine(defaults.Delay);   // 00:00:00.1000000

}
}

Constructors

AsyncRunOptions()

Initializes a new instance of the AsyncRunOptions class.

public AsyncRunOptions()

Remarks

The following table shows the initial property values for an instance of AsyncRunOptions.

PropertyInitial Value
Timeout00:00:05 (5 seconds)
Delay00:00:00.1000000 (100 milliseconds)

Properties

Delay

Gets or sets the delay between asynchronous operation attempts.

public TimeSpan Delay { get; set; }

Property Value

TimeSpan

The delay between asynchronous operation attempts. The default is 100 milliseconds.

Timeout

Gets or sets the timeout for the asynchronous operation.

public TimeSpan Timeout { get; set; }

Property Value

TimeSpan

The timeout for the asynchronous operation. The default is 5 seconds.

See Also