Tracking in Workflow Foundation

If you are tracking the progress of events in a workflow using a SqlTrackingService object you might have noticed you aren’t seeing any events in the database until the workflow is either finished or unloaded. In fact you won’t get to see any event until the WorkflowPersisted event has fired. The reason for this is that the default for the SqlTrackingService is to be transactional. Even though the docs claim the default for the SqlTrackingService.IsTransactional is false in fact it is true. This results in the records being written to the database but you won’t see them when querying because they are still locked in a transaction. So if you need or want to see the up-to-date events while the workflow is still executing you need to set the SqlTrackingService.IsTransactional to false before adding the service to the WorkflowRuntime.

 

If you want to see the tracking data itself you might start running SQL queries against the database. An easier way is to use the SqlTrackingQuery.TryGetWorkflow() to load an SqlTrackingWorkflowInstance instance with the tracking data. Te SqlTrackingWorkflowInstance object as properties to inspect the workflow status, the workflow events, the activity events and more.

 

Enjoy!

Maurice de Beijer
 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>