WorkflowInstance.TryUnload Método

Definição

Descarrega a instância de fluxo de trabalho da memória para o repositório de persistência quando a instância está suspensa ou ociosa.Unloads the workflow instance from memory to the persistence store when the instance is suspended or idle.

public:
 bool TryUnload();
public bool TryUnload ();
member this.TryUnload : unit -> bool
Public Function TryUnload () As Boolean

Retornos

Boolean

true se a instância de fluxo de trabalho foi descarregada, caso contrário, false.true if the workflow instance was unloaded; otherwise, false.

Exceções

Não há nenhum serviço de persistência registrado no mecanismo de runtime de fluxo de trabalho.There is no persistence service registered with the workflow runtime engine.

Exemplos

O exemplo a seguir demonstra o uso do método TryUnload para descarregar um fluxo de trabalho quando o evento é disparado WorkflowIdled .The following example demonstrates using the TryUnload method to unload a workflow when the WorkflowIdled event fires. Este exemplo é do uso do SDK de serviços de persistência, do arquivo Program.cs.This example is from the Using Persistence Services SDK sample, from the Program.cs file. Para obter mais informações, consulte usando serviços de persistência de exemplo.For more information, see Using Persistence Services Sample.

//Called when the workflow is idle - in this sample this occurs when the workflow is waiting on the
// delay1 activity to expire
static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
{
    Console.WriteLine("Workflow is idle.");
    e.WorkflowInstance.TryUnload();
}
'Called when the workflow is idle - in me sample me occurs when the workflow is waiting on the
' delay1 activity to expire
Shared Sub OnWorkflowIdled(ByVal sender As Object, ByVal e As WorkflowEventArgs)
    Console.WriteLine("Workflow is idle.")
    e.WorkflowInstance.TryUnload()
End Sub

Comentários

Se a instância de fluxo de trabalho estiver ociosa ou suspensa, TryUnload o usará o serviço de persistência para remover a instância de fluxo de trabalho da memória e mantê-la em um repositório de dados.If the workflow instance is idle or suspended, TryUnload uses the persistence service to remove the workflow instance from memory and persist it to a data store. Se não houver nenhum serviço de persistência registrado no WorkflowRuntime , o TryUnload lançará um InvalidOperationException .If there is no persistence service registered with the WorkflowRuntime, TryUnload throws an InvalidOperationException. Se a instância do fluxo de trabalho persistir com êxito, o tempo de execução gerará o WorkflowUnloaded evento e retornará true .If the workflow instance is successfully persisted, the runtime raises the WorkflowUnloaded event, and returns true. Unload retorna false se a instância de fluxo de trabalho já foi descarregada, foi encerrada, foi anulada ou já foi concluída.Unload returns false if the workflow instance has already been unloaded, has been terminated, has been aborted, or has already completed.

O host pode usar TryUnload para recuperar recursos do sistema de um fluxo de trabalho ocioso.The host can use TryUnload to reclaim system resources from an idle workflow.

Aplica-se a