Table of Contents

Class AsyncFuncFactory<TTuple, TResult>

Namespace
Cuemon.Threading
Assembly
Cuemon.Core.dll

Provides a way of invoking an Func<TResult> function delegate regardless of the amount of parameters provided.

public sealed class AsyncFuncFactory<TTuple, TResult> : MutableTupleFactory<TTuple> where TTuple : MutableTuple

Type Parameters

TTuple

The type of the n-tuple representation of a MutableTuple.

TResult

The type of the return value of the function delegate Cuemon.Threading.AsyncFuncFactory`2.Method.

Inheritance
AsyncFuncFactory<TTuple, TResult>
Inherited Members

Constructors

AsyncFuncFactory(Func<TTuple, CancellationToken, Task<TResult>>, TTuple)

Initializes a new instance of the AsyncFuncFactory<TTuple, TResult> class.

public AsyncFuncFactory(Func<TTuple, CancellationToken, Task<TResult>> method, TTuple tuple)

Parameters

method Func<TTuple, CancellationToken, Task<TResult>>

The function delegate to invoke.

tuple TTuple

The n-tuple argument of method.

AsyncFuncFactory(Func<TTuple, CancellationToken, Task<TResult>>, TTuple, Delegate)

Initializes a new instance of the AsyncFuncFactory<TTuple, TResult> class.

public AsyncFuncFactory(Func<TTuple, CancellationToken, Task<TResult>> method, TTuple tuple, Delegate originalDelegate)

Parameters

method Func<TTuple, CancellationToken, Task<TResult>>

The function delegate to invoke.

tuple TTuple

The n-tuple argument of method.

originalDelegate Delegate

The original delegate wrapped by method.

Methods

Clone()

Creates a shallow copy of the current AsyncFuncFactory<TTuple, TResult> object.

public override MutableTupleFactory<TTuple> Clone()

Returns

MutableTupleFactory<TTuple>

A new AsyncFuncFactory<TTuple, TResult> that is a copy of this instance.

Remarks

When thread safety is required this is the method to invoke.

ExecuteMethodAsync(CancellationToken)

Executes the function delegate associated with this instance.

public Task<TResult> ExecuteMethodAsync(CancellationToken ct)

Parameters

ct CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task<TResult>

A task that represents the asynchronous operation. The task result contains the return value of the function delegate associated with this instance.

Exceptions

InvalidOperationException

No delegate was specified on the factory.

OperationCanceledException

The ct was canceled.