Brian
Brian

Reputation: 211

Workflow: How can I signal one branch of a parallel activity to end from another branch?

I have a workflow with a parallel activity, where one branch does work and the other has a receive activity that can shut the workflow down (is the proper way to do this with a HandleExternalEvent instead?). The problem, of course, is that if the receive activity is never called, the work branch completes and waits on the receive activity branch. How can I signal the other branch to close the activity? I've toyed a bit with using a listen activity to hold the receive activity and a custom event activity, but I'm missing something on how to make that work, as well.

Upvotes: 1

Views: 1132

Answers (2)

javi
javi

Reputation: 74

You can use 'CompletionCondition", which is a parallel activity property that indicates whether parallel activity must finish if a branch ends.

You can check it here

Upvotes: 1

ndtreviv
ndtreviv

Reputation: 3624

You could cancel the listening activity on the alternate branch using the CancelActivity method on the ActivityExecutionContext object:

http://msdn.microsoft.com/en-us/library/system.workflow.componentmodel.activityexecutioncontext.cancelactivity.aspx

Upvotes: 0

Related Questions