What is a workflow? It is not quite clear yet.
What problems does a workflow solve? For the moment, it is just a vague concept that cannot be described in languages.
I. Example
Take vs2008 as an example to create a WWF program.
Drag a code in the toolbox to "activity ".
Open the attribute panel of codeactivity1, double-click in executecode, and enter, type the following code:
Namespace workflowconsoleapplication1 {public sealed partial class workflow1: sequentialworkflowactivity {public workflow1 () {initializecomponent ();} private void codeexecute (Object sender, eventargs e) {console. writeline ("Hello World -- workflow started! "); Console. readkey ();}}}
Startup, project, output as follows:
2. Create an application project
WWF workflows are all console programs. To better demonstrate them, create a Windows application as itsHost.
Create a Windows form application and reference the following controls.
As before, in the winform program, create a workflow project with the following structure:
Code in the winform Program (winform references the workflow project ):
Public partial class form1: FORM {// defines the runtime container private workflowruntime when the workflow is running; // defines the workflow instance private workflowinstance; Public form1 () {initializecomponent (); // The container workflowruntime = new workflowruntime (); workflowruntime when the workflow is started. startruntime ();} private void button1_click (Object sender, eventargs e) {// specify the workflow name to be referenced type = typeof (workflowconsoleapplication1.workflow1 ); // register a workflow instance workflowinstance = workflowruntime In the runtime container when the workflow is running. createworkflow (type); // start workflowinstance of the workflow instance. start ();}}
The workflow code console. Write () is changed to MessageBox. Show ();
Private void codeactivityincluexecutecode (Object sender, eventargs e) {MessageBox. Show ("Hello World -- workflow started! ");}
Click the button and the output is as follows:
Getting started with Microsoft workflow WWF <Article 1>