locked
WorkflowInvoker - Invoke and getting workflow guid RRS feed

  • Question

  • Does anyone know how to get the guid of a workflow that is synchronously run using the Invoke method? 

    Thanks in advance,
    John 

    Thursday, June 9, 2011 2:18 PM

Answers

  • Never fails.  Hunt around, get nothing. Post the question, and it clicks...  The solution is as simple as adding an extension:

     

    using System;
    using System.Activities.Hosting;
    using System.Collections.Generic;

    namespace [your namespace here]
    {
    class InvokeInformation : IWorkflowInstanceExtension
    {
    private WorkflowInstanceProxy m_instance;
    private Guid m_workflowInstanceGuid;

    IEnumerable<ObjectIWorkflowInstanceExtension.GetAdditionalExtensions()
    {
    return null;
    }

    void IWorkflowInstanceExtension.SetInstance(WorkflowInstanceProxy instance)
    {
    m_instance = instance;
    m_workflowInstanceGuid = instance.Id;
    }

    public Guid WorkflowInstanceGuid
    get { return m_workflowInstanceGuid; } }
    }
    }

     

    and to use it:

    WorkflowInvoker invoker = new WorkflowInvoker(activity);
    InvokeInformation invokeInformation = new InvokeInformation();
    invoker.Extensions.Add(invokeInformation);

    invoker.Invoke(inParams);

    Guid g = invokeInformation.WorkflowInstanceGuid;

    Thank you to this post for a nudge in the right direction.

    • Marked as answer by John Hennesey Thursday, June 9, 2011 2:48 PM
    Thursday, June 9, 2011 2:48 PM