Chaining Workflows Synchronously

In Ariel Schapiro: Shaggy’s Blog i found

"Chaining Workflows Synchronously: InvokeWorkflowSync Activity v1.0" sample.

That sample is developed in Beat1.

Please give me the link for Beat2.

or

What are the changes do we need to work in beat2.



Answer this question

Chaining Workflows Synchronously

  • chileto7

    You can find a link to the upgrade document on Paul Andrew's blog at http://blogs.msdn.com/pandrew/archive/2006/01/19/UpgradeWFBeta2.aspx.

    If you work through the document you will find that you can update the project to build correctly and get the first workflow started. Unfortunately the second workflow never starts because of a NullReferenceException that is ignored. The reason is that the WorklfowRuntime can no longer be accessed from the ActivityExecutionContext. Instead you can comment out all the code the uses the runtime and use the following instead to start the workflow:

    IStartWorkflow workflowInvoker = context.GetService(typeof(IStartWorkflow)) as IStartWorkflow;

    Guid instanceId = workflowInvoker.StartWorkflow(this.TargetWorkflow, dictionary1);

    The problem with using this method is that you aren’t able to add any handlers for the workflow completed event. This makes the workflow hang after the last workflow is started because of using the AutoResetEvent, which should only be used in a host and never used in activity's execute method.

    What I would recommend instead is to use an InvokeWorkflowActivity followed by a HandleExternalEventActivity in the invoking workflow. Then in the called workflow if it is sequential have a CallExternalMethodActivity as the last activity. For state machine have the CallExternalMethodActivity as the last activity in the next to last state, since the completed state can’t contain any children.



  • Chaining Workflows Synchronously