Objective:
By now we can see that WF4 contains a designer for a. xmal file and a runtime that invokes the activity. When you create your own workflow, you are also creating an activity,
Because the activity is a class that inherits System.Activities.Activity.
Activities can implement business processes, and some activities implement business processes by invoking other activities, such as sayhello activities that do not write text to the console, but rather through WriteLine activities.
To achieve this we will inherit a different base class System.Activities.CodeActivity.
Demo production:
1. Apply WF (ii) solution.
2. Create Sayhellocode activity, and write text to console via Console.WriteLine
Right-click the Helloworkflow project, select Add New Project, select Code Activity named Sayhelloincode;
In the Sayhelloincode class, delete the Text property and related, leaving only an empty execute empty method;
CodeActivity is an abstract class, so it is necessary to implement the Execute method when inheriting codeactivity, and execute this method to carry out your activity work;
Here we should rewrite execute such as:
3 update Proram.cs to call Sayhelloincode
:
4 recompile execution will succeed and display such as:
Then Demo3 is done.
Why do I need to create a code activity?
By writing business logic in code so that your business logic can be combined into larger business programs while using workflow runtime, this will benefit your threading model, data processing, and other aspects of the program's
Scalability has been greatly improved. (and the demo will talk about it).
WF (III)