Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
6 Months Free & No Setup Fees ASP.NET Hosting!
Search :       Advanced Search »
Home » WWF » Basic Introduction to Activities in Windows Workflow Foundation

Basic Introduction to Activities in Windows Workflow Foundation

In this article, we will take a look at the introductory concepts of Activities in the Windows Workflows Foundation.

Author Rank :
Page Views : 8055
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Team Foundation Server Hosting
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

What are Activities

 

  • Building Blocks of Workflows
  • Are organized in a tree structure to compose workflows
  • Can be simple or composite (containing child activities)
  • Can be sequential (executed in the flow of the workflow) or event-driven (triggered by external events) 

Activity Execution Context (AEC)

 

AEC is the execution environment created for an activity when the Start method is called.

New AECs are created when child activities of an activity are run more than once, thus allowing the various instances to run independently. An activity can close only when it's execution contexts have been completed.

 

Activity States

 

Activities move through various stages in the life cycle of the workflow. Various stages of an activity are: Initialized, Executing, Canceling, Closed, Compensating and Faulting.

 

Windows Workflow Foundation Base Activity Library

 

Windows Workflow Foundation includes a set of out-of-the-box activities. These are available in the Visual Studio toolbox and ready to be configured to be used.

 

Following is a listing of some of the commonly used activities

 

  • Code Activity: Allows you to add Visual Basic.Net or Visual C# code to be executed in the workflow
  • Delay Activity: Allows you to add a delay period in the activity. 

Composite Activities

 

  • Sequence Activity: Specify a set of activities as an activity branch for sequential execution.
  • Parallel Activity: Specify two or more child activity branches for parallel execution 

Conditional Activites

 

  • IfElse Activity: Allows conditional execution of a branch based on the first "true" condition encountered.
  • IfElseActivityBranch: Represents a branch of activities executed depending on the results of the conditions specified in an IfElseActivity.
  • While Activity: Allows looping within a workflow until the specified condition evaluates to true.
  • ConditionedActivityGroup: Executes child activities based on a condition. 

Conditions can be expressed in one of the following ways

 

  • Using code as Code Conditions
  • Declaratively using Rules: The Rule Condition editor can be used for specifying conditions as Rules.
  • Specifying a Policy Activity containing a collection of conditions and corresponding actions.

Policy activities are a collection of simple rules and enable forward chaining. Forward chaining is the ability of the actions of one rule to cause other dependent rules to be re-evaluated.

 

State Workflow Activities

 

The following activities are used for creating State Machine workflows

 

  • State Activity: Represents a state in a state machine workflow.
  • StateInitialization Activity: Used to contain child activities executed when a State Activity is entered.
  • SetState Activity: Allows transitioning to a different state in the state machine workflow. 

Event Driven Activites

 

  • EventDriven Activity: Executed when a specified event occurs.
  • Listen Activity: Composite activity containing child EventDrivenActivity activities. 

Abnormal Operation /Error Handling Activities

 

  • Compensate Activity: Code to compensate for an error in an in-progress workflow.
  • FaultHandlers Activity, FaultHandler Activity: Used to handle exceptions of a specified type.
  • Terminate Activity: Allows termination of a workflow when an error condition occurs.
  • Throw Activity:  Captures business exceptions. 

Transaction

 

  • TransactionScope Activity: Specify Transaction and Exception handling 

External Operations

 

  • InvokeWebService Activity: Invoke a web service from the workflow
  • InvokeWorkflow Activity: Invoke another workflow from the workflow
  • CallExternalMethod Activity: Communications with a local service
  • WebServiceOutput Activity: Enables the workflow to respond to a web service request made to it. Used for exposing the workflow as a web service. 

Custom Activities

 

The workflow foundation provides a number of activities out of the box. In any case, as you get into real life development for workflows, you will want to create custom activities, specialized for your requirements. Custom activities can incorporate knowledge on domain specific areas, incorporating vertical business functionality or can be setup as specialized building blocks for the horizontal architecture.

 

Custom Activities are developed by deriving from the Activity base class or from an activity that derives from the Activity class.

 

The visual aspect in design as well as execution is the one that differentiates the workflow based applications from other frameworks. The ActivityDesigner and CompositeActivityDesigner base classes provide designer features and these classes or their derived classes can be used for custom activities.

 

A number of ready to use custom activity samples are available at : http://wf.netfx3.com/files/14/default.aspx

 

Performance Considerations

 

Note the following performance considerations when developing your custom activities and/or workflows

 

  • Activity Execution Cloning - Especially complex AEC cloning can have a performance impact.
  • Activities with Transaction Support
  • Activities with Compensation Support
  • Execution Tracking
  • Activity Complexity 

Enable Transaction Support, Compensation support and Execution tracking only in areas where required.

 

Resources

 

Conclusion

 

In this article, we took a look at the introductory concepts of Activities in Windows Workflows Foundation. The workflow foundation is full of Activity goodies and custom activity functionality should be the icing on the cake.

Disclaimer:

This article is for purely educational purposes and is a compilation of notes, material and my understanding on this subject. Any resemblance to other material is an un-intentional coincidence and should not be misconstrued as malicious, slanderous, or any anything else hereof.  

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Dipal Choksi
Dipal Choksi has over 10 years of industry experience in team-effort projects and also as an individual contributor. She has been working on the .Net platform since the beta releases of .Net 1.0.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.