[WF] Quickstart sample Preface
Workflow Foundation (WF) always gives a very useful impression, but does not know how to use it. This is mainly because there are too many pre-jobs and a lot of underlying knowledge need to be integrated to complete writing: Execute activity, pause activity, re-read activity, continue activity, this series of workflow.
The following example is a record of my learning about Workflow Foundation. The main record is how to: integrate the basic WF function to execute an activity. The activity is automatically stored in the database when it is idle. When you need to continue executing the activity, read the activity from the database by ID to continue execution. We hope that with such an example, developers can quickly jump beyond the portal of the Workflow Foundation.
Example
Download program code
Click the following URL and extract the compressed file to obtain the relevant program code for this example:
(We recommend that you first read the related categories of Workflow Foundation and then view the sample content.)
Install Database
In the example program, you need to use the SQL database to store the current execution status of the activity. Therefore, you need to add the corresponding data table to the SQL database. Follow these steps to create related data tables for workflow in the SQL database:
- Create a blank Database: workflowinstancestore.
- In the newly created database, run the SQL command sqlworkflowinstancestoreschema. SQL in the sample program code.
- In the newly created database, execute the SQL command sqlworkflowinstancestorelogic. SQL in the sample program code.
Execute Program code
Use Visual Studio to enable and execute the sample project. You can see the following workflow: Execute activity, pause activity, re-read activity, and continue activity.
[WF] Quickstart sample