Reputation: 1
I am currently using a WorkFlowServiceHost in conjunction with the out-of-the-box SqlWorkflowInstanceStore for persistence purposes. I need to know when a completed workflow instance has actually been persisted in the database i.e I require notification immediately after the relevant row in the [System.Activities.DurableInstancing].InstancesTable has been updated with iscompleted = 1
I have inherited from the trackingparticipant class, and overridden the TRACK method.
I then do the following to add a profile..
Dim instanceQuery As New WorkflowInstanceQuery
instanceQuery.States.Add(WorkflowInstanceStates.Completed)
Dim runCompletedTrackingProfile As New TrackingProfile
runCompletedTrackingProfile.Name = "runCompletedTrackingProfile"
runCompletedTrackingProfile.Queries.Add(instanceQuery)
Dim trackingParticipant As New RunCompletedTrackingParticipant With {.TrackingProfile = runCompletedTrackingProfile}
_CommPayRunWorkFlowServiceHost.WorkflowExtensions.Add(trackingParticipant)
This all works fine, and if I put a breakpoint in my TrackingParticipant class it will be hit at the expected time. HOWEVER, at this point, although the workflow instance in memory is COMPLETED, the database has not yet been updated. I assume that this is because the persistence code is running on the same thread, because if I start another thread within my trackingparticipant, I can see that the 'iscompleted' field DOES get updated.
What is the most elegant way of achieving this without continually polling the database ? I've looked at the .WaitForEvents method on the instance store, but this does not appear to do what I need
Upvotes: 0
Views: 594
Reputation: 3279
Because the I/O is done async any design that calls for you to do this is likely to to produce fragile code. Why do you want to do this?
Upvotes: 1