If you have added a persistence service, then once the Workflow is completed it is removed from the persistence store.
Bayer
The workflow instance is persisted each time you indicate to the runtime to unload or when the workflow becomes idle. To me, the last time a workflow is persisted, can happen anytime the workflow meets the criteria above, and just before it is about to complete. Just curious...why are you trying to avoid persistence for the last time, before a workflow completes?
Bayer
Strangely, it is still persisted when it is about to complete. I do not
want this because it overwrites the previous persistence (I am using a
custom file persistence service). Thus, I want the workflow to be
persisted only when I tell it to be.
If there is a persistence service registered with the runtime the runtime will call WorkflowPersistenceService.SaveWorkflowInstanceState when a workflow instance completes or terminates. This doesn't mean that your persistence service is required to save the instance state. For example the SqlWorkflowPersistenceService does not serialize the instance at this point. All it does is delete the row from it's database. A persistence service can check the status of the instance by calling WorkflowPersistenceService.GetWorkflowStatus(rootActivity); in it's SaveWorkflowInstanceState method.
Thanks,
Joel West
MS SDE in WF runtime and hosting
This posting is provided "AS IS" with no warranties, and confers no rights