This documentation is archived and is not being maintained.

WorkflowCommitWorkBatchService Class

Allows custom logic for the commitment of work batches.

Namespace:  System.Workflow.Runtime.Hosting
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)

public abstract class WorkflowCommitWorkBatchService : WorkflowRuntimeService

When a work batch is committed the runtime calls into the WorkflowCommitWorkBatchService and gives it a delegate to call to do the actual committing of the work batch. The runtime still has the primary responsibility of committing the work batch but allows the WorkflowCommitWorkBatchService to insert itself in the process for customization around the commit process.

This process allows custom error handling logic. If the WorkflowCommitWorkBatchService owns the transaction, which is the case when the Transaction.Current property returns null therefore necessitating the need to create a new ambient transaction, it is allowed to call the delegate more than once, creating a new transaction for each call. The most common case for this for example is to handle intermittent network problems or SQL cluster failovers. If the call to the WorkflowCommitWorkBatchService.CommitWorkBatchCallback throws an exception WorkflowCommitWorkBatchService can catch this exception, start a new transaction and call the delegate again. This gives a level of resilience to workflow instance execution that otherwise would cause workflows to terminate.

The following example demonstrates a class that inherits from WorkflowCommitWorkBatchService.

//Implementation of the abstract WorkflowCommitWorkBatchService class 
class DefaultCommitWorkBatchService : WorkflowCommitWorkBatchService
    protected override void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback)
        // Call base implementation 
        catch (Exception e)
            // Report work batch commit failures
            Console.WriteLine("Work batch failed: " + e.Message.ToString());

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0