This seems to be more complicated than I first guessed. I have a workflow that needs to kick off another workflow in the code. How is this done? Do I have to get a reference to the current workflow instance’s WorkflowRuntime first?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think that the InvokeWorkflowActivity might be what you are looking for. I have used it for launching workflows from within other workflows, and it works well.
Just be aware of the fact that the new workflows (just as all workflows) are executed asynchronously, so the “parent workflow” will continue executing directly after having launched the child workflow.
If you (for whatever reason) can’t use the InvokeWorkflowActivity (for instance, if the new workflow is to be started from code within a service which is called from the parent workflow), you will in one way or another get hold of the workflow runtime instance.
The way I have approached this scenario is to declare an event in the service interface, and have the workflow host attach a listener to that event when the service is added to the runtime. Then you will have a code point that can be called from the service (through raising the event), that will also have access to the runtime; then you have all you need to launch the new workflow.