![]() ![]() | ||||
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename
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()) { SqlTrackingService tracking = new SqlTrackingService(@"Data Source=.\sqlexpress;Initial Catalog=WorkflowTracking;Integrated Security=True"); tracking.IsTransactional = false; workflowRuntime.AddService(tracking); workflowRuntime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(workflowRuntime_WorkflowIdled); WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication2.Workflow1)); instance.Start(); Console.ReadLine(); } } 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 | ||