Before creating a simple workflow example, open vs2010 and run the "file. new. project, and select the "workflow" node. Here we will find four templates.
In the "name" column, enter chapter01, select the "workflow console application" template, and click OK.
(Figure 1-1)
WF"Hello world !"
In this case, the template will automatically generate a framework with simple workflow functions, as shown in vs2010 IDE.
(Figure 1-2)
We can simply divide the development platform into three work areas: 1 as the workflow flow design area, 2 as the variable and parameter design area, and 3 as the workflow toolbox.
In area 2, you can click "variable", "parameter", or "import" multiple times to enable or disable it. The "variables" are designed as follows:
(Figure 1-3)
"Parameters" include:
(Figure 1-4)
If we take the "activity" ratio in the workflow as a class, the "variables" and "Parameters" are similar to the "variables" and "Parameters" in the method ". It is particularly worth noting that the parameter in the activity needs to specify its "visible field ".
Design Workflow
In Area 1 in Figure 1-2, we will find that the initial workflow is empty. If we want a workflow to output "Hello World !", Follow these steps:
Drag a "sequence" from the control flow of the toolbox to Area 1, and then drag a "writeline" from the Toolbox base to the newly added "sequence, the final effect is as follows:
(Figure 1-5)
In the selected "writeline", the base attributes are as follows:
(Figure 1-6)
In this case, you only need to enter(Note: The quotation marks are in English):
"Hello world! "
At the same time, change the code in prsag. CS to the following:
using System;using System.Linq;using System.Activities;using System.Activities.Statements;namespace Chapter01{ class Program { static void Main(string[] args) { WorkflowInvoker.Invoke(new Workflow1()); Console.WriteLine("Press ENTER to exit"); Console.ReadLine(); } }}
The following two lines of code are added:
Console. writeline ("press enter to exit ");
Console. Readline ();
(Note: These two lines of code are mainly used to view the results during running. If not, the code will flash off after running)
Press F5 to run: