Activity communication  
Author Message
Igor24





PostPosted: Windows Workflow Foundation, Activity communication Top

Hi,

i would really like one straightforward, "for dummies" (well, I am, what can I say), example of sending information (properties, data) between activities in running workflow. For example, I want to create CDO.message object in one activity, then pass it down to other activity to do some work on it, and so forth.

Most examples deals with host- workflow communication, and I just can find one example that can help me with my problem. I know that probably it is possible to do it with Dependency Properties, but I don't know how.

Thanks,

Igor



Software Development for Windows Vista9  
 
 
Steve Danielson





PostPosted: Windows Workflow Foundation, Activity communication Top

Hi Igor,

If you need to use an object in multiple places in a workflow, probably the easiest way is to store the actual instance of the CDO.message object as a workflow member, and refer to it from your various activities. Dependency properties is exactly the way to do this. In your custom activity create a dependency property of the type that you want to share. You can use Workflow snippets for this. When you are done you will have something like this (this example is for a string property)

public static DependencyProperty MyCustomStringProperty = System.Workflow.ComponentModel.DependencyProperty.Register("MyCustomString", typeof(string), typeof(Activity1));

[Description("Custom Shared property")]

[Category("Shared Props")]

[Browsable(true)]

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]

public string MyCustomString

{

get

{

return ((string)(base.GetValue(Activity1.MyCustomStringProperty)));

}

set

{

base.SetValue(Activity1.MyCustomStringProperty, value);

}

}

When you add this activity to the workflow, you can then bind this property to a member variable of the workflow.

In your second activity, create the same type of dependency property, and when you add it to the workflow, bind it to the same variable. Both activities will use the same instance of the object, and this is a method to allow you to share an object across multiple custom activities.

I can post a sample if this info doesn't get you started in the right direction.

Thanks,

Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm




 
 
Steve Danielson





PostPosted: Windows Workflow Foundation, Activity communication Top

Here is the sample posted to my blog:

http://blogs.msdn.com/sdanie/archive/2006/06/23/644379.aspx

Thanks,

Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm