Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Persist Method
Collapse the table of content
Expand the table of content

WorkflowApplication.Persist Method

.NET Framework 4.6 and 4.5

Persists a workflow instance to an instance store.

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

public void Persist()

If the persist operation does not complete within 30 seconds, a TimeoutException is thrown.

If the workflow instance was previously loaded from persistence, then the same InstanceStore used to load the workflow is used for persistence. If the workflow was created and has not yet been persisted, then an InstanceStore must be configured before calling this method or else an InvalidOperationException is thrown when this method is called.

The following example calls Persist to persist a workflow instance before the workflow is started. This example is part of the StartAndUnloadInstance method in the Persisting a Workflow Instance sample.

WorkflowApplication application = new WorkflowApplication(activity);

application.InstanceStore = instanceStore;

//returning IdleAction.Unload instructs the WorkflowApplication to persists application state and remove it from memory  
application.PersistableIdle = (e) =>
{
    return PersistableIdleAction.Unload;
};

application.Unloaded = (e) =>
{
    instanceUnloaded.Set();
};


//This call is not required  
//Calling persist here captures the application durably before it has been started
application.Persist();
id = application.Id;
application.Run();

instanceUnloaded.WaitOne();

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft