Using CancellationScope activity
As we know, the Parallel activity will not finish execution until all of its child branches have finished execution. Sometimes, we want to break the parallel if one of its branch finishes execution and cancel the other branches. To do this, we can use a CancellationScope
activity. In this task, we want to order products from two dealers (Dealer A and Dealer B) at the same time. In this situation, the two dealers are in a competition, and so the one who ships the product faster wins the business.
How to do it...
- Create a Workflow Console Application:
Create a new Workflow Console Application project and name it
UseCancellationScope
. - Create a code workflow file:
Add to the project a new class file and name it
WorkflowWithCancellationScope.cs ...
Get Microsoft Windows Workflow Foundation 4.0 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.