Export (0) Print
Expand All

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
public abstract class WorkflowCommitWorkBatchService extends WorkflowRuntimeService
public abstract class WorkflowCommitWorkBatchService extends WorkflowRuntimeService
Not applicable.

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 a null reference (Nothing in Visual Basic) 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
        try
        {
            base.CommitWorkBatch(commitWorkBatchCallback);
        }
        catch (Exception e)
        {
            // Report work batch commit failures
            Console.WriteLine("Work batch failed: " + e.Message.ToString());
            throw;
        }
    }
}

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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft