Search code examples
workflow-foundationworkflow-foundation-4parent-childstate-machine

Abort child workflow by a trigger


I am executing dynamically loaded child work-flows by a parent workflow. while the child workflow is executing I want to abort the current child workflow and start a new workflow from dynamically loaded file (.xaml) according to the user inputs from the parent workflow.
My parent workflow is a state machine which is exposed as a service and it has a state which executes another loaded child workflow in the entry method of the state (using Microsoft.Activities.Extensions ).I want child workflow to be changed according to a trigger. Child workflow can be a state machine or sequential .


Solution

  • There are two ways a workflow can be aborted.

    1. The host WorkflowApplication
    2. The workflow itself can use the Terminate activity

    In your case, Microsoft.Activities.Extensions uses a WorkflowInvoker to invoke the workflow and you cannot abort the child workflow so your only option is to have the child workflow check for some kind of a "signal" to terminate if it is looping.

    This "signal" could be the presence of a file, record in a database etc.