The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SqlWorkflowInstanceStore.InstanceLockedExceptionAction Property

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Specifies the action to be taken when the persistence provider catches an InstanceLockedException.

Namespace:   System.Activities.DurableInstancing
Assembly:  System.Activities.DurableInstancing (in System.Activities.DurableInstancing.dll)

public InstanceLockedExceptionAction InstanceLockedExceptionAction { get; set; }

Property Value

Type: System.Activities.DurableInstancing.InstanceLockedExceptionAction

The action to be taken when the persistence provider catches an InstanceLockedException

Specify what action a service host should take when a workflow service instance experiences an InstanceLockedException. The service host receives an InstanceLockedException when it tries to lock an instance that is already locked by another owner. The possible values are in the following list:

  • None. The service host does not attempt to lock the instance and passes the InstanceLockedException to the caller.

  • BasicRetry. The service host reattempts to lock the instance with a linear retry interval and passes the exception to the caller at the end of the sequence.

  • AggressiveRetry. The service host reattempts to lock the instance with an exponentially increasing delay and passes the InstanceLockedException to the caller at the end of the sequence. The intervals are short in the beginning in an attempt to acquire the lock as quickly as possible and the intervals gets bigger with every unsuccessful attempt.

The following code sample demonstrates using InstanceLockedExceptionAction in a SqlWorkflowInstanceStore. This example is from the Built-in Configuration sample.

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;

    // Open service host.

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

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

.NET Framework
Available since 4.0
Return to top