简体   繁体   中英

Terminate Workflow from custom code activity

Is it possible to terminate a workflow from within a custom code activity? I'd like to change my code activity to end the workflow if certain conditions are met otherwise carry on.

I've found System.Workflow.ComponentModel.TerminateActivity but i'd like to call it from within my custom code activity.

I've got

System.Workflow.ComponentModel.TerminateActivity Terminate = new System.Workflow.ComponentModel.TerminateActivity();

but how to i execute the activity?

Options that I see:

  1. set something (eg a Variable) that can be inspected throughout your Workflow, and use regular conditional branching (eg If activities) to decide the flow.

  2. throw an exception from C#/VB, and have it leak out uncaught

System.Activities.Statements.TerminateWorkflow terminator =
    new System.Activities.Statements.TerminateWorkflow();
terminator.Reason = "TEST";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM