SqlWorkflowInstanceStore.RunnableInstancesDetectionPeriod Proprietà

Definizione

Specifica il periodo di tempo dopo il quale l'archivio di istanze del flusso di lavoro SQL esegue un'attività di rilevamento per rilevare le istanze del flusso di lavoro eseguibili o attivabili nel database di persistenza dopo il ciclo di rilevamento precedente.

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

Valore della proprietà

Restituisce TimeSpan.

Esempio

Nell'esempio di codice seguente viene illustrato l'uso di RunnableInstancesDetectionPeriod in un oggetto 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

SqlWorkflowInstanceStore Esegue un'attività interna che riattiva periodicamente e controlla se nel database di persistenza sono presenti istanze eseguibili. Un'istanza è eseguibile, se non è nello stato sospeso o nello stato completato e soddisfa le condizioni seguenti:

  • L'istanza è stata sbloccata e il timer in sospeso è scaduto.

  • L'istanza viene sbloccata e il relativo stato è In esecuzione.

  • L'istanza ha un blocco scaduto.

L'archivio di istanze del flusso di lavoro SQL genera HasRunnableWorkflowEvent quando trova un'istanza eseguibile nel database e trova anche un host del flusso di lavoro in grado di caricare l'istanza in esecuzione nel computer.

Quando un host del flusso di lavoro riceve questo evento, esegue l'oggetto TryLoadRunnableWorkflowCommand sull'archivio di istanze per caricare l'istanza nella memoria.

Il tipo della proprietà è TimeSpan e il valore è del formato "hh:mm:ss". Il valore minimo è "00:00:01" (1 sec). Se omesso, il valore predefinito è "00:00:05" (5 sec). Questo parametro è un parametro facoltativo.

Si applica a