Steve1999

Hello,

in my state machine workflow, using the lab's "StateMachineTrackingService", i noticed that i get a "OnInstanceCompleted" just before a "OnStateExecuting"

The OnStateExecuting comes from the TrackingService. OnWorkflowCompleted comes from the runtime.

Setting breakpoints in the code shows me clearly that the runtime is firing the workflowcompleted before the tracking service gets the OnStateExecuting.

This messes up my workflow instance auditing.

How do i fix this issue Thanks!


Re: Windows Workflow Foundation getting a workflowcompleted before a state change notification from tracking

Matt Milner - Pluralsight

What is probably happening is your workflow is completing and in that transaction is sending all the data to the tracking service. If you want to audit the workflow, don't use the completed event on the runtime, use the closed status on the workflow itself using the tracking service. That way you'll get more consistent results as they are all coming from the tracking service.

Matt






Re: Windows Workflow Foundation getting a workflowcompleted before a state change notification from tracking

Steve1999

Thanks Matt, that makes good sense.

How, specifically, do you get "closed status on the workflow itself"

E.g., when i get the TrackExecuting for the last state in the state machine, is there a way to ask:

if ( (record.ActivityType as StateActivity).IsFinalState() )