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.
Create a Workflow Console Application:
Create a new Workflow Console Application project and name it
UseCancellationScope
.Add to the project a new class file and name it
WorkflowWithCancellationScope.cs
. Fill the file with the following code:using System.Activities; using System.Activities.Statements; using System; namespace UseCancellationScope { class WorkflowWithCancellationScope { public Activity GetInstance...