共用方式為


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 秒) 。

適用於