Fault Handling in a Flowchart Activity Using TryCatch
This sample shows how the TryCatch activity can be used within a complex control flow activity.
In this sample, a promotion code and number of children are passed as variables to a Flowchart activity that calculates a discount based on formulae that correspond to the promotion code. The sample includes imperative code and workflow designer versions of the sample.
The following table details the variables for the
|promoCode||The promotion code. Type: String
The possible values with description in parentheses:
- Single (Single)
- MNK (Married with no kids.)
- MWK (Married with kids.)
|numKids||The number of children. Type: int|
CreateFlowchartWithFaults activity uses a FlowSwitch<T> activity that switches on the
promoCode argument and calculates the discount using the following formula.
|MWK||15 + (1 – 1/
To use this sample
Using Visual Studio 2010, open the FlowchartWithFaultHandling.sln solution file.
To build the solution, press CTRL+SHIFT+B.
To run the solution, press F5.
The samples may already be installed on your computer. Check for the following (default) directory before continuing.
If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.