WF from Getting started to mastering (seventh chapter): Operation of basic activities

Source: Internet
Author: User
Tags error handling visual studio

After completing this chapter, you will learn:

1. Know how to use sequence activities

2. Know how to use code activities

3. Know how to throw an exception and process it in a workflow

4. Know how to pause and terminate your workflow instance in code

In this chapter, we will formally introduce a set of activities that we have seen before: sequence activities and code activities. But I believe that proper error handling is critical to well-designed and well-run software, so we'll look at how to use activities in a workflow to throw exceptions, catch exceptions, or even pause and terminate your workflow. Let's start with the sequence activity.

Using Sequential active objects

In fact, it is not entirely true that we have seen sequence activities. When we create a workflow application, we actually use the sequentialworkflow activity, but the general meaning is the same: This activity contains other activities that are to be executed sequentially. This can be compared to the parallel execution using the parallel activity, and we will see the parallel activity in chapter 11th ("Parallel activity").

When you perform a task in a particular order, you must complete the tasks in turn, which is usually necessary.

The sequence activity is a composite activity that we have discussed briefly in chapter fourth ("Introduction to activities and Workflow types"). It contains other activities that must be performed in sequence. You can include other combinations of activities, including parallel activities, within the parent sequence activity. However, the child activities are executed sequentially, one after the other, even if the parallel execution flows contained in the child activities themselves.

Let's use the sequence activity to create a simple workflow. We'll use the code activity again, and the more detailed details about it will be discussed in the next section, "Using code activities." To understand the behavior of a particular workflow activity, we will go back to the console based application. For a console-based application, you usually need to write less code because you don't have to process the user interface. (But as the book progresses, we'll create other graphical test cases as well.) )

Create a workflow that uses the sequence activity

1. Download the source code in this chapter, the final version of this example is available in the "Sequencer Completed" directory, which you can use Visual Studio 2008 to open and view its running results directly. The "Sequencer" directory is the practice version, and we'll start with this example, starting with Visual Studio 2008 to open the solution.

2. Add a sequential Workflow library project to our solution with the project name "Sequencerflow".

3. Drag a sequence activity from the toolbox to Visual Studio's Workflow View Designer.

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.