This documentation is archived and is not being maintained.

PersistenceParticipant Class

This class allows both WorkflowApplication and WorkflowServiceHost to participate in persistence process. A persistence participant derives from the PersistenceParticipant class or the PersistenceIOParticipant class (derived class of the PersistenceParticipant class), implements abstract methods, and then add an instance of the class as a workflow instance extension. The WorkflowApplication and WorkflowServiceHost look for such extensions when persisting an instance and invoke appropriate methods at appropriate times.

Namespace:  System.Activities.Persistence
Assembly:  System.Activities (in System.Activities.dll)

public abstract class PersistenceParticipant

The PersistenceParticipant type exposes the following members.

Protected methodPersistenceParticipantInitializes an instance of the PersistenceParticipant class.

Protected methodCollectValuesA host invokes this method on a custom persistence participant to collect read-write values and write-only values, to be persisted.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMapValuesA host invokes this method after it is done with collecting the values in the first stage. The host forwards two read-only dictionaries of values it collected from all persistence participants during the first stage (CollectValues stage) to this method for mapping. The host adds values in the dictionary returned by this method to the collection of write-only values.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodPublishValuesThe host invokes this method and passes all the loaded values in the InstanceData() collection (filled by the LoadWorkflowCommand or LoadWorkflowByInstanceKeyCommand) as a dictionary parameter.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

A host executes the following steps (or stages) when persisting an instance:

  1. Collects values to be persisted.

  2. Maps fields of monolithic structured values to individual values.

  3. Issues the SaveWorkflowCommand to the persistence provider.

  4. Performs I/O under the persistence transaction.

A host completes a stage before beginning the next stage. For example when persisting, the host collects values from all the persistence participants before moving to the second stage. In the second stage, the host provides all the values collected in the first stage to all persistence participants in the second stage for mapping. In the third stage, the host provides all the collected values in the first and second stages to the persistence provider when invoking the SaveWorkflowCommand. Then in the fourth stage, the host provides all the collected values to all the persistence IO participants under the persistence transaction.

A host executes the following stages when loading a persistence instance:

  1. Issues the LoadWorkflowCommand and LoadWorkflowByInstanceKeyCommand to the persistence provider.

  2. Performs I/O under the persistence transaction.

  3. Publishes the loaded values.

At the highest level, workflow instance extensions that derive from the PersistenceParticipant class can participate in the first (Collect) and second (Map) stages of persisting process and the third stage (Publish) of loading process. Workflow instance extensions deriving from the PersistenceIOParticipant class can additionally participate in the fourth stage of the persisting process and the second stage of the loading process (I/O).

The following code sample demonstrates creating a class that derives from PersistenceParticipant. This example is from the Hiring Process sample.

public class HiringRequestInfoPersistenceParticipant: PersistenceIOParticipant
    public HiringRequestInfoPersistenceParticipant()
        : base(true, false)

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.