Synchronization of Workflow instances?

I would like to know if there is a possibility to synchronize after asynchronously workflow calls.
Consider the following situation:
I have an invoke workflow activity inside a while activity. The workflow is invoked n times, until the condition of the while activity evaluates to false. From the view inside the while activity the asynchronous workflow call is required, but from the view outside I would like to know the point of time, when all of the workflow instances have been completed.

Any ideas



Answer this question

Synchronization of Workflow instances?

  • JCL

    Considering the Matt's idea about a "parallel shapes" i have this suggestion. (i hope it doesn't sound crazy)

    You could have your main workflow, inside this workflow you could have an invokeWorkflow activity that invokes a "Caller" workflow  where you're going to do the n calls to the other workflows.the main workflow pass to a eventSink activity inside a while activity, the evensink activity is listening all the workflows called by the "caller workflow" and the condition to end this while is that all the workflows called by the "caller workflow" ar completed.

        Main Worlflow
                 |
          InvokeWorkflow activity  - - - - - - -  --------------Caller Workflow
                 |                                                                                  |
           While (all called workflows are completed)                   your While
                 |                                                                                  |
            EvenSink                                                           your invokeWorkflow Activity - -


    your Called workflow is gonna have an InvokeMethod activity which is listened by the eventSink of the main workflow


    I hope you could understand what i'm trying to explain.




  • Brack0893

    You can use a local service to communicate between the two items, having the called workflows call  a method on the service which raises an event to the calling workflow. You'll need to pass instance IDs to the workflows you call so they can use it to raise the events.  You can have another while loop that waits until you have received events from all of the called workflows. 

    Be aware, if your called workflows are short lived, you might have a race condition where you haven't started all of your workflows before you start getting responses.  You might be able to avoid this with some parallel shapes or other design considerations that allow you to listen for incoming events while sending out the initial calls. 

    HTH,
    Matt



  • Synchronization of Workflow instances?