locked
[Newbie] How to terminate a workflow from within an activity? RRS feed

  • Question

  • I have a composite activity (custom class derived off of Sequence) that has a listen + couple of event sinks along with few other things.

    This acitivity is included in a workflow. What I would like to do is terminate the workflow say upon receipt of some event - say for eg. manager denies request so there is no point in continuing the workflow.

    1. How do I do that?
    2. Are there any un-desirable effects of terminating the workflow in this manner?

    thanks
    Jay
    Wednesday, November 30, 2005 6:21 PM

Answers

  • Jay,

    You can use the "Terminate" activity to terminate the workflow.  The effects of doing this:
    -The runtime will raise the WorkflowTerminated event.
    -The instance's state will be disposed (removed from persistence), no more events will be deliverable to it, and its execution will end.

    Hope this helps.
    Wednesday, November 30, 2005 8:24 PM
  • You can dynamically add a Terminate activity. Alternatively you could use an IfElse with a condition to choose to execute the Terminate activity.

    Regards,
    Paul
    Wednesday, November 30, 2005 11:02 PM

All replies

  • Jay,

    You can use the "Terminate" activity to terminate the workflow.  The effects of doing this:
    -The runtime will raise the WorkflowTerminated event.
    -The instance's state will be disposed (removed from persistence), no more events will be deliverable to it, and its execution will end.

    Hope this helps.
    Wednesday, November 30, 2005 8:24 PM
  • Thanks Arjun.

    However the difficulty I have is - the workflow is constructed dynamically and likewise the decision to terminate is to be made dynamically based on what transpires in the activity.

    Is it possible to 'invoke' a Terminate activity from any (custom) activity programmatically?

    rgds
    Jay
    Wednesday, November 30, 2005 10:59 PM
  • You can dynamically add a Terminate activity. Alternatively you could use an IfElse with a condition to choose to execute the Terminate activity.

    Regards,
    Paul
    Wednesday, November 30, 2005 11:02 PM