Windows Workflow Foundation (II): several concepts in the example

Source: Internet
Author: User
Tags log4net
In the previous article, I introduced the basic concepts of WWF, mainly at that level, as well as the functions and modules of each level.
This time, we will use some small examples to demonstrate the significance of these concepts of WWF, mainly explaining the running models of host and WWF.
Then, explain the activity and workflow types in detail.

The following types of projects can be created by WWF:
Console Application;
Windowsform application;
Webform application;
Windows service. We will introduce the use of WebService later.

Let's first look at the content of WWF through a console application.
creation method:
1: Open vs2005, create a workflow project, and select the consoleapplication template.
2: On the sequential workflow design page (for the difference between sequential and State, see Windows Workflow Foundation (1): Basic concepts ), add a codeactivity (the content of the activity will be written later ).
3: Write such processing in codebehind of codeactivity
console. writeline ("Hello, world"); // how is it Hello, world? Not hello, Roy?
4: Start the Code of workflow.
_ workflowruntime = new system. workflow. runtime. workflowruntime ("workflowruntime");
try
{< br> _ workflowruntime. startruntime ();
}< br> catch
{}

Look, there are several WWF contents.
First,ProgramTemplates (many on the Internet, should be well understood ).
Then, activity, activity, and WWF process the core of business logic. Here, a codeactivity is used to write some code for processing. These processes are included in WWF of course. You can see another new feature of the designer: if some parameters are not filled in, it will prompt during the design.
Workflowruntime is behind. He will process it in his own processing space-some problems about the processing space will be discussed soon. The parameter is the WWF name configured in webconfig, for example:
<Configsections>
<Section name = "log4net" type = "log4net. config. log4netconfigurationsectionhandler, log4net"/>
<Section name = "workflowruntime" type = "system. workflow. runtime. configuration. workflowruntimesection, system. workflow. runtime, version = 3.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"/>
</Configsections>

The preceding example may not be satisfactory. Let's look at a complicated application of Windows Workflow Foundation in webapplication and use statemechineworkflow. Mainly look at the design steps and content.
In this example, we can see that
1: WWF runtime, configuration, and startup. Here is the basis for running WWF. The above is also a simple reference.
2: The data object documentservice and the event with externaldataexchange inheritance
3: a wwf object: Business Process
4: wwf host: WWF program

The explanations for this example already exist. The concept to be explained here isRuntime Space.
"Workflows run in their own context, a context that inckides data and execution, so they naturally run in a separate thread from the host"

Host is a runtime space, such as the runtime space of webform or winform, while WWF runs in another program space (which has its own context ).
This means that the host processing space is different from the WWF processing space (thread, this translation may have problems), and there is a communication problem between them.
We may all know that communication between program domains is similar.

In order to trigger the processing in the WWF processing space, the host space must communicate through the event. This is the meaning of the documentservice, this is why he must be able to serializable (this object is passed in Different spaces for serialization/deserialization ).

Similarly, if you want the activity in WWF to access the control in the host (for example, modify the text attribute of a button in the winform form), you can access the win form in another tread, the thread is not secure, so you have to use this method to access:
Thefrom. button1.invoke (....);

In order to solve the data exchange, WWF has several dedicated activities to do this. They are updatedata; selectdata; waitfordata; waitforquery. The following describes the four activities in detail.

The next article will detail the classification and usage of the activity.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.