Table of Contents

Class TaskFuncFactory<TTuple, TResult>

Namespace
Cuemon
Assembly
Cuemon.Core.dll

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

public sealed class TaskFuncFactory<TTuple, TResult> : TemplateFactory<TTuple> where TTuple : Template

Type Parameters

TTuple

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

TResult

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

Inheritance
Object
TaskFuncFactory<TTuple, TResult>
Inherited Members

Constructors

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

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

public TaskFuncFactory(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.

Methods

Clone()

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

public override TemplateFactory<TTuple> Clone()

Returns

TemplateFactory<TTuple>

A new TaskFuncFactory<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 System.Threading.CancellationToken.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

System.InvalidOperationException

No delegate was specified on the factory.

System.OperationCanceledException

The ct was canceled.