Custom Persistence Service Sample
This sample demonstrates how to write a custom persistence service that is used by the workflow runtime to save workflow instance state to a file when unloading a workflow from memory.
In the sample, the workflow waits five seconds during a DelayActivity activity. Because workflowRuntime.UnloadOnIdle is set to true, the runtime engine serializes the instance state by using the configured state persistence service. In this case, the runtime is configured to use the custom file persistence service to persist instance state as a file. The configuration is done by the AddService method.
A custom persistence service has to derive from the WorkflowPersistenceService abstract class and provide custom implementation for its methods. The purpose of letting an application provide the runtime with its specific persistence service is to enable scenarios beyond the default SqlWorkflowPersistenceService that persists to a SQL Server database.
The following figure shows the expected output of this sample.
To build the sample
Download the sample by clicking Download Sample.
This extracts the sample project to your local hard disk.
Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.
Go to the source directory of the sample.
At the command prompt, type MSBUILD <Solution file name>.
To run the sample
- In the SDK Command Prompt window, run the .exe file in the CustomPersistenceService\bin\debug folder (or the CustomPersistenceService\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.
© 2007 Microsoft Corporation. All rights reserved.