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 p开发者_如何转开发roper 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.
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
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
精彩评论