This documentation is archived and is not being maintained.

Durable Delay in XAMLX

This topic applies to Windows Workflow Foundation 4 (WF4).

This sample demonstrates how to use a durable delay, which is a delay that persists the workflow to a durable device during the delay.


The sample workflow contains two messages to a local file that are separated by a delay. When the delay is triggered, the workflow is unloaded and waits 5 seconds in the workflow instance store before being reloaded in memory.

The .xamlx file is a workflow service that is hosted in Visual Studio. Visual Studio uses Cassini that uses a workflow service host to host the workflow.

In addition to hosting the workflow, the workflow service host manages the workflow instances by loading and unloading them. To start an instance of the Windows Workflow Foundation (WF) definition (on the workflow service host), set a client that sends a message to the Receive activity in the workflow. This Receive has its CanCreateInstance property set to true, enabling it to create a new instance of the workflow once it receives a message.

During initialization, an unload instance behavior is added to the configuration file that specifies to the workflow service host under which it should unload an instance to the persistence store (database). For this sample, it unloads the instance immediately after the workflow goes idle (when the delay is triggered).

To use this sample

  1. Open a Visual Studio 2010 command prompt.

  2. Navigate to the DurableDelayXamlx\CS folder.

  3. Run Setup.cmd.

  4. Run Visual Studio 2010 as an administrator.

  5. Open the DurableDelayXamlx.sln solution file.

  6. In Solution Explorer, right-click the solution and select Properties.

  7. Select Multiple startup projects and set both projects to Start.

  8. To build the solution, press CTRL+SHIFT+B.

  9. To run the solution, press CTRL+F5.

To uninstall this sample

  1. Open a Visual Studio 2010 command prompt.

  2. Navigate to the DurableDelayXamlx\CS folder.

  3. Run Cleanup.cmd.

Ee834527.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing.


If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.