locked
How do I find out what step is waiting? RRS feed

  • Question

  • Hi,

     

    Is there anyway of figuring out which step in an idled workflow is waiting on a response?

     

    I have a few Listen steps in my sequential workflow that waits on a events.  I would like to show a brief overview of the workflow to the user, when it has been idled, and indicate where abouts they are in its processing.

     

    I have looked at the Activity.ExecutionStatus but that doesn't help.

     

    Any ideas?

     

    Thanks,

     

    Craig

    Wednesday, July 25, 2007 5:06 AM

Answers

  • You can use GetWorkflowQueueData method on  WorkflowInstance from the host, to get the information of the event on which the workflow is waiting for. Here is the sample code from "Canceling a Workflow Sample"

    http://msdn2.microsoft.com/en-us/library/ms742169.aspx

     

    static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
            {
                WorkflowInstance workflow = e.WorkflowInstance;

                Console.WriteLine("\n...waiting for 3 seconds... \n");
                Thread.Sleep(3000);
               
                // what activity is blocking the workflow
                ReadOnlyCollection<WorkflowQueueInfo> wqi = workflow.GetWorkflowQueueData();
                foreach (WorkflowQueueInfo q in wqi)
                {
                    EventQueueName eq = q.QueueName as EventQueueName;
                    if (eq != null)
                    {
                        // get activity that is waiting for event
                        ReadOnlyCollection<string> blockedActivity = q.SubscribedActivityNames;
                        Console.WriteLine("Host: Workflow is blocked on " + blockedActivity[0]);
                       
                        // this event is never going to arrive eg. employee left the company
                        // lets send an exception to this queue
                        // it will either be handled by exception handler that was modeled in workflow
                        // or the runtime will unwind running compensation handlers and exit the workflow
                        Console.WriteLine("Host: This event is not going to arrive");
                        Console.WriteLine("Host: Cancel workflow with unhandled exception");
                        workflow.EnqueueItem(q.QueueName, new Exception("ExitWorkflowException"), null, null);
                    }
                }
            }

     

    Wednesday, July 25, 2007 8:34 PM

All replies

  • You can use tracking service for this. For example create enum with values kind of Step1, Step2, ...

    and use tracking to set the value from workflow. Host will have access to the values, though you will need to store the value on a host level for active workflows (in DB for example).

     

    Thanks,

    Konstantin.

     

    Wednesday, July 25, 2007 1:36 PM
  • You can use GetWorkflowQueueData method on  WorkflowInstance from the host, to get the information of the event on which the workflow is waiting for. Here is the sample code from "Canceling a Workflow Sample"

    http://msdn2.microsoft.com/en-us/library/ms742169.aspx

     

    static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
            {
                WorkflowInstance workflow = e.WorkflowInstance;

                Console.WriteLine("\n...waiting for 3 seconds... \n");
                Thread.Sleep(3000);
               
                // what activity is blocking the workflow
                ReadOnlyCollection<WorkflowQueueInfo> wqi = workflow.GetWorkflowQueueData();
                foreach (WorkflowQueueInfo q in wqi)
                {
                    EventQueueName eq = q.QueueName as EventQueueName;
                    if (eq != null)
                    {
                        // get activity that is waiting for event
                        ReadOnlyCollection<string> blockedActivity = q.SubscribedActivityNames;
                        Console.WriteLine("Host: Workflow is blocked on " + blockedActivity[0]);
                       
                        // this event is never going to arrive eg. employee left the company
                        // lets send an exception to this queue
                        // it will either be handled by exception handler that was modeled in workflow
                        // or the runtime will unwind running compensation handlers and exit the workflow
                        Console.WriteLine("Host: This event is not going to arrive");
                        Console.WriteLine("Host: Cancel workflow with unhandled exception");
                        workflow.EnqueueItem(q.QueueName, new Exception("ExitWorkflowException"), null, null);
                    }
                }
            }

     

    Wednesday, July 25, 2007 8:34 PM