Custom Persistence Service Sample

Download 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.

Customer persistence sample output

To build the sample

  1. Download the sample by clicking Download Sample.

    This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  1. 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.

See Also

Reference

WorkflowPersistenceService
SqlWorkflowPersistenceService

Other Resources

Using Persistence Services Sample
Custom Persistence Service Sample
Windows Workflow Persistence Services
Exercise 4 : Using Runtime Services
Task 3 : Using the Windows Workflow Persistence Service

© 2007 Microsoft Corporation. All rights reserved.