Class TaskFuncFactory<TTuple, TResult>
Provides an easy way of invoking an Func<TResult> function delegate regardless of the amount of parameters provided.
Inherited Members
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public sealed class TaskFuncFactory<TTuple, TResult> : TemplateFactory<TTuple> where TTuple : Template
Type Parameters
Name | Description |
---|---|
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. |
Constructors
| Improve this Doc View SourceTaskFuncFactory(Func<TTuple, CancellationToken, Task<TResult>>, TTuple)
Initializes a new instance of the TaskFuncFactory<TTuple, TResult> class.
Declaration
public TaskFuncFactory(Func<TTuple, CancellationToken, Task<TResult>> method, TTuple tuple)
Parameters
Type | Name | Description |
---|---|---|
Func<TTuple, CancellationToken, Task<TResult>> | method | The function delegate to invoke. |
TTuple | tuple | The n-tuple argument of |
Methods
| Improve this Doc View SourceClone()
Creates a shallow copy of the current TaskFuncFactory<TTuple, TResult> object.
Declaration
public override TemplateFactory<TTuple> Clone()
Returns
Type | Description |
---|---|
TemplateFactory<TTuple> | A new TaskFuncFactory<TTuple, TResult> that is a copy of this instance. |
Overrides
Remarks
When thread safety is required this is the method to invoke.
ExecuteMethodAsync(CancellationToken)
Executes the function delegate associated with this instance.
Declaration
public Task<TResult> ExecuteMethodAsync(CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | ct | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
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
Type | Condition |
---|---|
InvalidOperationException | No delegate was specified on the factory. |
OperationCanceledException | The |