Getting in to Windows Workflow Foundation — Creating Custom Activity!

This is the first time i am writing about some thing about my final year project!!

Finally!

First How to create a Custom activity In windows Workflow foundation.

1.      Select the File | New | Project menu command.

2.      Visual Studio displays the New Project dialog box.

3.      Select the Visual C# | Workflow project type.

4.      Select the Workflow Activity Library template.

Change the name of the project to Helloworld activity or what so ever you want

 the code view of the activity would look some thing like this

 

public partial class Activity1: SequenceActivity
{
public Activity1()
{
InitializeComponent();
}
}

Next you have to Override a method that executes your custom activity .

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
Console.WriteLine(“Hello world”);
return ActivityExecutionStatus.Closed;
}Will print Hello world and the activity gets finished. the Execute function is minimal to be overloaded in order to make custom execution.

Now in the workflow you’re designing you can add activities like this

private void InitializeComponent()
{
this.CanModifyActivities = true;
//this.delayActivity1 = new System.Workflow.Activities.DelayActivity();
this.Activity2 = new ActivityLibrary2.Activity1();
//
// Custom activity

//
this.Activity2.Name = “Activity2”;
//
// Workflow1
//

/// Here custom activity is being added on the workflow

this.Activities.Add(this.Activity2);
this.Name = “Workflow1”;
this.CanModifyActivities = false;

}

This is what i have understood by now… Signing off… 🙂

Advertisements

~ by Azeem on November 28, 2007.

2 Responses to “Getting in to Windows Workflow Foundation — Creating Custom Activity!”

  1. i tried this and really its not working!

  2. What’s the error you’re getting !?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: