Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    Object
    WorkerParent
    WorkerBase
    WorkerBase<WhileActionWorker<T>>
    WhileActionWorker<T>
    Implements
    IDisposeOnFinished
    Inherited Members
    WorkerBase<WhileActionWorker<T>>.AddCompletedCallback(Func<WhileActionWorker<T>, OutcomeStatus, Task<OutcomeStatus>>)
    WorkerBase<WhileActionWorker<T>>.AddRanCallback(Func<WhileActionWorker<T>, OutcomeStatus, WorkerParentChildrenState, Task<OutcomeStatus>>)
    WorkerBase<WhileActionWorker<T>>.AddStartingCallback(Func<WhileActionWorker<T>, Task<ProgressStatus>>)
    WorkerBase.AddCompletedCallback(Func<WorkerBase, OutcomeStatus, Task<OutcomeStatus>>)
    WorkerBase.AddRanCallback(Func<WorkerBase, OutcomeStatus, WorkerParentChildrenState, Task<OutcomeStatus>>)
    WorkerBase.AddStartingCallback(Func<WorkerBase, Task<ProgressStatus>>)
    WorkerBase.DefaultIsStartable()
    WorkerBase.ErroredPortErrorsWorkerProtected
    WorkerBase.ErrorOutputs
    WorkerBase.EscalateError
    WorkerBase.Inputs
    WorkerBase.IsStartable
    WorkerBase.Outputs
    WorkerBase.Parent
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, WorkerBase, WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(WorkerBase, TLastWorker)
    WorkerBase.SucceededSequence<TLastWorker>(TLastWorker)
    WorkerParent.AddChildCompletedCallback(Action<WorkerBase>)
    WorkerParent.AddStartingChildrenCallback(Func<WorkerParent, Task<ProgressStatus>>)
    WorkerParent.Children
    WorkerParent.DisposeOnFinished<TDisposable>(TDisposable)
    WorkerParent.GetDownstreamFactory<TInput>()
    WorkerParent.HasChildren
    WorkerParent.IsCanceled
    WorkerParent.IsCompleted
    WorkerParent.IsCreated
    WorkerParent.IsError
    WorkerParent.IsFailed
    WorkerParent.IsFatal
    WorkerParent.IsRunning
    WorkerParent.IsSucceeded
    WorkerParent.KeepChildrenLevels
    WorkerParent.Locator
    WorkerParent.LogFactory
    WorkerParent.Logger
    WorkerParent.MaxRunningChildren
    WorkerParent.Name
    WorkerParent.RemoveChildren()
    WorkerParent.RescheduleChildren()
    WorkerParent.RunChildrenAsync(Boolean)
    WorkerParent.RunChildrenAsync()
    WorkerParent.Status
    WorkerParent.Item[String]
    WorkerParent.ToString()
    WorkerParent.WorkerSystem
    WorkerParent.DebugCommands
    WorkerParent.AggregateErrorOutputRows
    WorkerParent.AggregateOutputRows
    WorkerParent.AggregateWorkersCompleted
    WorkerParent.InstantCompleted
    WorkerParent.InstantCreated
    WorkerParent.InstantStarted
    WorkerParent.RunningDuration
    Namespace: actionETL
    Assembly: actionETL.dll
    Syntax
    public class WhileActionWorker<T> : WorkerBase<WhileActionWorker<T>>, IDisposeOnFinished
    Type Parameters
    Name Description
    T

    The type the evaluateFunc parameters return.

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Action<WhileActionWorker<T>> iterateAction

    The synchronous action to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Func<WhileActionWorker<T>, OutcomeStatus> iterateFunc

    The synchronous function to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that must return true to continue looping, or false to stop looping.

    Func<WhileActionWorker<T>, Task<OutcomeStatus>> iterateFuncAsync

    The asynchronous function to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Func<WhileActionWorker<T>, Task> iterateActionAsync

    The asynchronous action to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Action<WhileActionWorker<T>> iterateAction

    The synchronous action to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Func<WhileActionWorker<T>, OutcomeStatus> iterateFunc

    The synchronous function to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Func<WhileActionWorker<T>, Task<OutcomeStatus>> iterateFuncAsync

    The asynchronous function to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 null.

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<Boolean> isStartableFunc

    Function to calculate the worker start constraint; it should return true for startable and false for not startable. Defaults to startable if null.

    Func<WhileActionWorker<T>, Boolean> evaluateFunc

    A function that should return true to continue looping, otherwise false.

    Func<WhileActionWorker<T>, Task> iterateActionAsync

    The asynchronous action to execute each iteration, optionally creating child workers.

    Exceptions
    Type Condition
    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException
    • workerParent - All workers must have a parent. The top level workers have the worker system as parent.
    • evaluateFunc
    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    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 Task describing the success or failure of the worker. An asynchronous async implementation would e.g. return OutcomeStatus.Succeeded on success, while a synchronous implementation would return OutcomeStatus.SucceededTask.

    Overrides
    WorkerParent.RunAsync()

    Implements

    IDisposeOnFinished

    See Also

    ForEachActionWorker<TItem>
    EscalateError
    In This Article
    Back to top Copyright © 2020 Envobi Ltd