The Problem SolverWIndows Workflow Foundation
HomeShow ChangesPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename



18-8-2008 16:53:4718-8-2008 16:35:09

List all versions

State History

Is a member of the StateMachineWorkflowInstance object.

A simple example to print the state history every time a workflow goes idle:

static void Main(string[] args)
    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
        workflowRuntime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(workflowRuntime_WorkflowIdled);

        WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication2.Workflow1));


static void workflowRuntime_WorkflowIdled(object sender, WorkflowEventArgs e)
    WorkflowRuntime runtime = sender as WorkflowRuntime;
    StateMachineWorkflowInstance instance = new StateMachineWorkflowInstance(runtime, e.WorkflowInstance.InstanceId);

    Console.WriteLine("State history:");
    foreach (var item in instance.StateHistory)
        Console.WriteLine("\t{0}", item);

When you use this you might receive a InvalidOperationException with message: 'StateHistory' property requires the 'System.Workflow.Runtime.Tracking.SqlTrackingService' service. This is because it uses the SqlTrackingService to retreive all previous states from.

Wiki Usage

This wiki site is supposed to be a shared resource. As a shared resource everyone is encouraged to add new content or modify existing content!

Enjoy the WF wiki.

Recent Topics

  • StateHistory