SqlWorkflowInstanceStore.HostLockRenewalPeriod Proprietà

Definizione

Specifica il periodo di tempo entro il quale l'host rinnova il blocco su un'istanza del servizio del flusso di lavoro.

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

Valore della proprietà

Periodo di tempo.

Esempio

Nell'esempio di codice seguente viene mostrato l'utilizzo di HostLockRenewalPeriod in SqlWorkflowInstanceStore.

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

Commenti

Se l'host non rinnova il blocco (ovvero estende il lease) in questo periodo di tempo, il provider di persistenza sblocca l'istanza che può venire bloccata da un altro host. Il valore è un TimeSpan valore del formato "hh:mm:ss". Il valore minimo consentito è "00:00:01" (1 sec). Il valore predefinito di questa proprietà è "00:00:30" (30 secondi).

Si applica a