SqlWorkflowInstanceStore.HostLockRenewalPeriod 属性

定义

指定时间段,宿主必须在该时间段内续订其在工作流服务实例上的锁。

public:
 property TimeSpan HostLockRenewalPeriod { TimeSpan get(); void set(TimeSpan value); };
public TimeSpan HostLockRenewalPeriod { get; set; }
member this.HostLockRenewalPeriod : TimeSpan with get, set
Public Property HostLockRenewalPeriod As TimeSpan

属性值

时间段。

示例

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

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();
}

注解

如果宿主没有在此时间段中使用此属性续订锁(换句话说,延长租约),此持久性提供程序将解除实例锁定,另一个宿主可以锁定该实例。 该值是 “ TimeSpan hh:mm:ss” 形式的 。 允许的最小值为“00:00:01” (1 秒) 。 此属性的默认值为“00:00:30”(30 秒)。

适用于