[WF4]Correlate Multiple Receive Activities

Consider such a workflow:

There are two Receive activities. The first Receive activity will create a workflow instance. The second Receive activity functions as a bookmark activity. Imagine that there are two such workflow instances:

A WCF request comes to call the second Receive activity. Which one should take care of the request? We can use correlation to solve the problem.

First, we need to create a CorrelationHandle, and then an Int32 Variable data.

Correlation handle will link two Receive activities together. And the two receive will paired base on the data. For example, if we create a workflow instance with data:10. Then we can invoke its second Receive activity by passing in "10".

The configuration steps:
1. Specify the parameter for the Receive activities:

2. Then configure the CorrelationWith and CorrelationOn properties.

Correlation.xamlx (6.91 kb)

CSWF4ActivitiesCorrelation.zip (8.02 kb)

blog comments powered by Disqus