SqlWorkflowInstanceStore.InstanceCompletionAction 属性

定义

指定要在工作流实例完成后采取的操作。 可能的值为“DeleteNothing”和“DeleteAll”。 默认值为“DeleteAll”。 如果该属性设置为“DeleteNothing”,则持久性提供程序将在工作流实例完成后将所有实例数据和元数据保留在持久性数据库中。 如果该属性设置为“DeleteAll”,则持久性提供程序将在工作流实例完成后删除所有实例数据和元数据。

public:
 property System::Activities::DurableInstancing::InstanceCompletionAction InstanceCompletionAction { System::Activities::DurableInstancing::InstanceCompletionAction get(); void set(System::Activities::DurableInstancing::InstanceCompletionAction value); };
public System.Activities.DurableInstancing.InstanceCompletionAction InstanceCompletionAction { get; set; }
member this.InstanceCompletionAction : System.Activities.DurableInstancing.InstanceCompletionAction with get, set
Public Property InstanceCompletionAction As InstanceCompletionAction

属性值

要在工作流完成后采取的操作。

示例

下面的代码示例演示如何在 SqlWorkflowInstanceStore 中使用 InstanceCompletionAction。

static void Main(string[] args)
{
    // Create service host.
    WorkflowServiceHost host = new WorkflowServiceHost(new CountingWorkflow(), new Uri(hostBaseAddress));

    // Add service endpoint.
    host.AddServiceEndpoint("ICountingWorkflow", new BasicHttpBinding(), "");

    // Define SqlWorkflowInstanceStoreBehavior:
    //   Set interval to renew instance lock to 5 seconds.
    //   Set interval to check for runnable instances to 2 seconds.
    //   Instance Store does not keep instances after it is completed.
    //   Select exponential back-off algorithm when retrying to load a locked instance.
    //   Instance state information is compressed using the GZip compressing algorithm.
    SqlWorkflowInstanceStoreBehavior instanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior(connectionString);
    instanceStoreBehavior.HostLockRenewalPeriod = new TimeSpan(0, 0, 5);
    instanceStoreBehavior.RunnableInstancesDetectionPeriod = new TimeSpan(0, 0, 2);
    instanceStoreBehavior.InstanceCompletionAction = InstanceCompletionAction.DeleteAll;
    instanceStoreBehavior.InstanceLockedExceptionAction = InstanceLockedExceptionAction.AggressiveRetry;
    instanceStoreBehavior.InstanceEncodingOption = InstanceEncodingOption.GZip;
    host.Description.Behaviors.Add(instanceStoreBehavior);

    // Open service host.
    host.Open();

    // Create a client that sends a message to create an instance of the workflow.
    ICountingWorkflow client = ChannelFactory<ICountingWorkflow>.CreateChannel(new BasicHttpBinding(), new EndpointAddress(hostBaseAddress));
    client.start();

    Console.WriteLine("(Press [Enter] at any time to terminate host)");
    Console.ReadLine();
    host.Close();
}

注解

可能的值为“DeleteNothing”和“DeleteAll”。 默认值为“DeleteAll”。 如果该属性设置为“DeleteNothing”,则持久性提供程序将在工作流实例完成后将所有实例数据和元数据保留在持久性数据库中。 如果该属性设置为“DeleteAll”,则持久性提供程序将在工作流实例完成后删除所有实例数据和元数据。

适用于