WorkflowInstance.Unload Méthode

Définition

Décharge l'instance de workflow de la mémoire dans le magasin de persistances. Cet appel se bloque jusqu’à la fin du travail planifié en cours ou à la fin de la portée d’une transaction.

public:
 void Unload();
public void Unload ();
member this.Unload : unit -> unit
Public Sub Unload ()

Exceptions

Aucun service de persistance n'est enregistré auprès du moteur d'exécution de workflow.

Exemples

L'exemple suivant montre comment appeler Unload sur un objet WorkflowInstance.

// Create a WorkflowRuntime object
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a new instance of the out-of-box SqlWorkflowPersistenceService
SqlWorkflowPersistenceService persistenceService =
   new SqlWorkflowPersistenceService(
   "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;");
// Add the service to the runtime
workflowRuntime.AddService(persistenceService);
// Create a WorkflowInstance object
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(Workflow1));
// Start the workflow instance
workflowInstance.Start();
//Unload the instance
workflowInstance.Unload();
' Create a WorkflowRuntime object
Dim workflowRuntime As New WorkflowRuntime()
' Create a new instance of the out-of-box SqlWorkflowPersistenceService
Dim persistenceService As _
   New SqlWorkflowPersistenceService( _
   "Initial Catalog=SqlPersistenceServiceData Source=localhostIntegrated Security=SSPI")
' Add the service to the runtime
workflowRuntime.AddService(persistenceService)
' Create a WorkflowInstance object
Dim workflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow1))
' Start the workflow instance
workflowInstance.Start()
'Unload the instance
workflowInstance.Unload()

Remarques

Unload est synchrone ; autrement dit, il est renvoyé après avoir effectué toute action qu'il exécute. Si l'instance de workflow n'est pas inactive, l'exécution attend que l'instance puisse être interrompue. Une instance peut être interrompue uniquement une fois que l’élément de travail planifié en cours a été exécuté ; c’est en général ce qui se produit lorsque l’activité en cours d’exécution est renvoyée par sa méthode Execute. Toutefois, si l’instance exécute une TransactionScopeActivity, la portée de transaction doit effectuer l’exécution avant que l’instance puisse être interrompue. Unload utilise ensuite le service de persistances pour supprimer l'instance de workflow de la mémoire et la rendre persistante dans un magasin de données. Si aucun service de persistance n'est enregistré avec le WorkflowRuntime, Unload lève une InvalidOperationException. Si l'instance de workflow a pu être rendue persistante, l'exécution déclenche l'événement WorkflowUnloaded.

L'hôte peut utiliser Unload pour libérer les ressources système d'un workflow inactif.

S’applique à