Workflow Programming Step-by-Step (4:invokeworkflowactivity activity)

Source: Internet
Author: User
Tags reference

First, Introduction

You can start another workflow asynchronously from one workflow by using the invokeworkflowactivity activity. The invokeworkflowactivity activity completes before the started workflow is executed and the next activity in the Workflow branch executes.

Attention:

* WF does not support recursive workflows. If workflow A can start Workflow B, workflow B can neither start workflow a directly nor start any workflows that call workflow a directly or indirectly.

* Invokeworkflowactivity activity requires the workflow runtime to create a new workflow using the scheduler service that is currently attached to the runtime.

* The workflow that is invoked will only be able to receive input parameters. Obtaining an output parameter after a workflow completes is not supported because the activity invokes the workflow asynchronously.

* Standard communication rules between workflows are applied to communicate with new workflow instances created by Invokeworkflowactivny activities.

The steps for using the invokeworkflowactivity activity are as follows:

* Drag a invokeworkflowactivity to the desired position in the workflow.

* Set the Targetworkflow property to the type (type) of the workflow that you want to execute.

* Set the desired value for the targetworkflow.

When you set the Targetworkflow property, the Activity provides a dialog box that allows you to navigate to the correct type from all references to the list of active types, but only the classes that derive from the activity are displayed in the list. In order to reference a new workflow type, you must first add a reference to the project or assembly that contains the workflow. Please refer to the illustrations later in this article for a specific dialog box.

Once the Targetworkflow property is defined, the parameter collection properties of the workflow are updated with any other properties defined in Targetworkflow. Allows developers to set values for any desired property in the Properties window, either by setting a static value or by binding properties to other properties of the current workflow or other properties of other activities.

Invokeworkflowactivity provides a invoking event allowing developers to use code processing. This event is triggered before a new workflow is created, which gives the developer the opportunity to complete some setup tasks before starting a new workflow.

An important aspect of Invokeworkflowactiv is that the workflow will execute asynchronously, so it will not wait for the execution of the new workflow to complete. Cannot get output parameters for another workflow because the execution is asynchronous. It is often necessary to establish additional communication mechanisms with the host to obtain its output.

Second, create a console Sequence Workflow sample program framework

Description: The Invokeworkflowactivitydemo sample created in this article demonstrates how to invoke another work subworkflow within a state machine workflow and defines a local service interface implementation. Use the HandleExternalEvent activity to invoke an external event to wait for the invoked workflow instance to finish executing. The activity needs to wait for an event to be triggered to continue the workflow, while in Program.cs it sets the event to be triggered only after the specified non-host workflow has finished executing. So this implements an effect that waits for the called workflow to complete before it continues to execute.

Important NOTE:

The learning of this example is based on many new concepts in the WWF (not included in previous tutorials), and is fully understood in the context of the following references. Individual difficulties, please do not worry too much, I will be in the following series of detailed analysis of the article.

Follow the steps below to create a console state machine Workflow sample program:

1. Start VS2008, click menu "File" | " New "|" Project, create a console state machine Workflow sample program named Invokeworkflowactivitydemo.

2. After that, the system automatically opens the Workflow designer interface.

3. Drag four State activities from the Toolbox to the Workflow Designer. Then, in turn, drag two stateinitialization activities into the first two state activities, and then drag a eventdrivenactivity activity into the third State activity. Finally, we use the drag handle to create the transformation relationship of four State activities, and get the situation as shown in the figure.

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.