locked
CallExternalMethod to Terminate a Persisted Workflow RRS feed

  • Question

  • I have a sequential WF with a CallExternalMethod Activity attached. I am wanting to tell the host to terminate another persisted workflow. I have a method in the workflow codebehind that uses the SqlTrackingWorkflowInstance class along with SqlTrackQuery to return a specific workflowInstanceId from the tracking/persistence store.

     

    I am attempting to terminate that specific workflow from my current workflow. I know in beta2 it is not possible to directly cancel another workflow. I must create an interface to talk back to the host. I've done this, added the dataExchangeService to my host and added the new service to it.

     

    My workflow is successfully querying the tracking/persistence DB for the GUID, and it's passing the guid back to the host successfully but I don't know how to actually get the host to terminate the workflow.

     

    I know that I cannot instantiate a new workflowRuntime instance since it's already running. Can someone explain to me how to correctly get the existing runtime instance and call the GetWorkflow(instanceId).Terminate() method?

     

    Many thanks,

     

    Craig

    Friday, May 12, 2006 8:06 PM

Answers

  • Hi Craig,

    It sounds like you're using our out-of-box messaging.  If you're trying to get the WorkflowRuntime from inside the method on your local service (i.e. the target method of your CallExternalMethod activity), then your service needs to implement WorkflowRuntimeService.

    WorkflowRuntimeService provides you the workflow runtime through a protected property called Runtime that is populated when your service is added to the workflow runtime in the host.

    This should let you do what you want from the method of your local service.

    Hope this helps,
    Angel

    Friday, May 12, 2006 8:35 PM
    Moderator

All replies

  • Hi Craig,

    It sounds like you're using our out-of-box messaging.  If you're trying to get the WorkflowRuntime from inside the method on your local service (i.e. the target method of your CallExternalMethod activity), then your service needs to implement WorkflowRuntimeService.

    WorkflowRuntimeService provides you the workflow runtime through a protected property called Runtime that is populated when your service is added to the workflow runtime in the host.

    This should let you do what you want from the method of your local service.

    Hope this helps,
    Angel

    Friday, May 12, 2006 8:35 PM
    Moderator
  • Craig -

        An alternative would be to simply pass a the runtime reference to the local data exchange service when it is created either in constructor/as property update yourself and use it to terminate the workflow from the GUID.

     

    -Vignesh

    Friday, May 12, 2006 9:23 PM
  • Angel, thanks this worked!
    Monday, May 15, 2006 1:11 PM