Class WhileActionWorker<T>
A worker that executes a callback once for each iteration in a while-loop. The callback can optionally create child workers, which will be removed after each iteration, except on the last iteration, allowing them to be inspected.
Note that workers should not be added by the evaluateFunc
callback,
since they will be removed before they are run. Instead use the iterateAction
,
iterateActionAsync
, iterateFunc
, or iterateFuncAsync
parameters
to add child workers. Less commonly, child workers can also be added (typically by the
worker parent) before the worker runs, in which case they will run on the
first iteration (if any), but not on later iterations.
Any failure status returned from the user callback or escalated from worker children
will halt the iteration. One can suppress Error
escalation on selected child workers
(by setting EscalateError to false), e.g. to implement retry-on-error
functionality.
Note that if a dedicated parent worker is not needed (e.g. to group child workers), and all
child workers can be created before any child worker is started,
it is simpler to instead use a regular while
statement to perform the work,
e.g. creating child workers. See
Instantiating Workers via Looping
for details.
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public class WhileActionWorker<T> : WorkerBase<WhileActionWorker<T>>, IDisposeOnFinished
Type Parameters
Name | Description |
---|---|
T | The type the |
Constructors
WhileActionWorker(WorkerParent, String, Func<WhileActionWorker<T>, Boolean>, Action<WhileActionWorker<T>>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a synchronous action once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<WhileActionWorker<T>, bool> evaluateFunc, Action<WhileActionWorker<T>> iterateAction)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Action<WhileActionWorker<T>> | iterateAction | The synchronous action to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<WhileActionWorker<T>, Boolean>, Func<WhileActionWorker<T>, OutcomeStatus>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a synchronous function once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<WhileActionWorker<T>, bool> evaluateFunc, Func<WhileActionWorker<T>, OutcomeStatus> iterateFunc)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Func<WhileActionWorker<T>, OutcomeStatus> | iterateFunc | The synchronous function to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<WhileActionWorker<T>, Boolean>, Func<WhileActionWorker<T>, Task<OutcomeStatus>>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a asynchronous function once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<WhileActionWorker<T>, bool> evaluateFunc, Func<WhileActionWorker<T>, Task<OutcomeStatus>> iterateFuncAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that must return |
Func<WhileActionWorker<T>, Task<OutcomeStatus>> | iterateFuncAsync | The asynchronous function to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<WhileActionWorker<T>, Boolean>, Func<WhileActionWorker<T>, Task>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a asynchronous action once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<WhileActionWorker<T>, bool> evaluateFunc, Func<WhileActionWorker<T>, Task> iterateActionAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Func<WhileActionWorker<T>, Task> | iterateActionAsync | The asynchronous action to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<Boolean>, Func<WhileActionWorker<T>, Boolean>, Action<WhileActionWorker<T>>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a synchronous action once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<WhileActionWorker<T>, bool> evaluateFunc, Action<WhileActionWorker<T>> iterateAction)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Action<WhileActionWorker<T>> | iterateAction | The synchronous action to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<Boolean>, Func<WhileActionWorker<T>, Boolean>, Func<WhileActionWorker<T>, OutcomeStatus>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a synchronous function once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<WhileActionWorker<T>, bool> evaluateFunc, Func<WhileActionWorker<T>, OutcomeStatus> iterateFunc)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Func<WhileActionWorker<T>, OutcomeStatus> | iterateFunc | The synchronous function to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<Boolean>, Func<WhileActionWorker<T>, Boolean>, Func<WhileActionWorker<T>, Task<OutcomeStatus>>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a asynchronous function once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<WhileActionWorker<T>, bool> evaluateFunc, Func<WhileActionWorker<T>, Task<OutcomeStatus>> iterateFuncAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Func<WhileActionWorker<T>, Task<OutcomeStatus>> | iterateFuncAsync | The asynchronous function to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
WhileActionWorker(WorkerParent, String, Func<Boolean>, Func<WhileActionWorker<T>, Boolean>, Func<WhileActionWorker<T>, Task>)
Initializes a new instance of the WhileActionWorker<T> worker that executes a asynchronous action once for each iteration in a while-loop.
Declaration
public WhileActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<WhileActionWorker<T>, bool> evaluateFunc, Func<WhileActionWorker<T>, Task> iterateActionAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<WhileActionWorker<T>, Boolean> | evaluateFunc | A function that should return |
Func<WhileActionWorker<T>, Task> | iterateActionAsync | The asynchronous action to execute each iteration, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
Methods
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing. In this case, the base class base.RunAsync()
must
be called for the worker to function correctly.
Typically, this worker is used without overriding this method.
Declaration
protected override Task<OutcomeStatus> RunAsync()
Returns
Type | Description |
---|---|
Task<OutcomeStatus> | A |